Parsing NewsML and storing to Database


Could anyone please help me out with a parsing logic that will parse NewsMLfiles and inserts into the database. NewsMl files are standard xml files with a metadata. My objecive is to parse the NewsML file and extract the feed data and insert into a SQL Server database. The database will have correspounding fields which matches the NewsML feed tags. The parser should work in such a way that it will fetch all the entries from the XML file and inserts into the appropriate column in the database. Later i use these information in the database to populate in a website.You can use any .NET supporting language like C#, VB etc.
I have attached the sample of NewsML .
If I am not clear with any portion of my question, plz mention.
<?xml version="1.0" encoding="UTF-8"?>
  <!ENTITY % xhtml SYSTEM "">
<!--src: rtr2newsml0.990-->
<NewsML Duid="MTFH09658_2002-07-03_01-40-47_2640656_NEWSML">
    <Catalog Href=""/>
        <NewsService FormalName="RTR_TNS"/>
        <NewsProduct FormalName="TXT"/>
        <Priority FormalName="3"/>
    <NewsItem Duid="MTFH09658_2002-07-03_01-40-47_2640656_NEWSITEM">
                <RevisionId Update="N" PreviousRevision="0">1</RevisionId>
            <DateLabel>2002-07-03 01:40:47 GMT (Reuters)</DateLabel>
            <NewsItemType FormalName="News"/>
            <Status FormalName="Usable"/>
            <Urgency FormalName="3"/>
        <NewsComponent EquivalentsList="no" Essential="no" Duid="MTFH09658_2002-07-03_01-40-47_2640656_MAIN_NC" xml:lang="en">
            <TopicSet FormalName="HighImportance">  <Topic Duid="ts_1">  <TopicType FormalName="Geography"/>  <FormalName Scheme="N2000">AF</FormalName>  <Description xml:lang="en">Afghanistan</Description>  <Property FormalName="CountryGrouping" Value="EMRG"/>  <Property FormalName="WhyPresent" Value="Classifier"/>  </Topic>  <Topic Duid="ts_2">  <TopicType FormalName="Geography"/>  <FormalName Scheme="N2000">ASIA</FormalName>  <Description xml:lang="en">Asia</Description>  <Property FormalName="WhyPresent" Value="Ancestor"/>  </Topic>  <Topic Duid="ts_3">  <TopicType FormalName="Country Grouping"/>  <FormalName Scheme="N2000">EMRG</FormalName>  <Description xml:lang="en">Emerging countries</Description>  <Property FormalName="WhyPresent" Value="Classifier"/>  </Topic>  <Topic Duid="ts_4">  <TopicType FormalName="Geography"/>  <FormalName Scheme="N2000">US</FormalName>  <Description xml:lang="en">United States of America</Description>  <Property FormalName="WhyPresent" Value="Classifier"/>  </Topic>  <Topic Duid="ts_5">  <TopicType FormalName="Geography"/>  <FormalName Scheme="N2000">PK</FormalName>  <Description xml:lang="en">Pakistan</Description>  <Property FormalName="WhyPresent" Value="Classifier"/>  </Topic>  <Topic Duid="ts_6">  <TopicType FormalName="Government and private aid"/>  <FormalName Scheme="N2000">AID</FormalName>  <FormalName Scheme="IPTCSubjectCodes">04008007</FormalName>  <Description xml:lang="en">Private/Government Aid</Description>  <Property FormalName="WhyPresent" Value="Classifier"/>  </Topic>  <Topic Duid="ts_7">  <TopicType FormalName="INTERNATIONAL RELATIONS"/>  <FormalName Scheme="N2000">DIP</FormalName>  <FormalName Scheme="IPTCSubjectCodes">11002000</FormalName>  <Description xml:lang="en">Diplomacy; International Relations</Description>  <Property FormalName="WhyPresent" Value="Ancestor"/>  </Topic>  <Topic Duid="ts_8">  <TopicType FormalName="Reuters Legacy Code"/>  <FormalName Scheme="N2000">NEWS</FormalName>  <Description xml:lang="en">General News</Description>  <Property FormalName="WhyPresent" Value="Classifier"/>  </Topic>  <Topic Duid="ts_9">  <TopicType FormalName="Reuters Legacy Code"/>  <FormalName Scheme="N2000">FEA</FormalName>  <Description xml:lang="en">Features (German)</Description>  <Property FormalName="WhyPresent" Value="Classifier"/>  </Topic>  <Topic Duid="ts_10">  <TopicType FormalName="HEALTH AND MEDICINE"/>  <FormalName Scheme="N2000">HEA</FormalName>  <FormalName Scheme="IPTCSubjectCodes">07000000</FormalName>  <Description xml:lang="en">Health and medicine</Description>  <Property FormalName="WhyPresent" Value="Classifier"/>  </Topic>  <Topic Duid="ts_11">  <TopicType FormalName="Lifestyle"/>  <FormalName Scheme="N2000">LIF</FormalName>  <FormalName Scheme="IPTCSubjectCodes">10000000</FormalName>  <Description xml:lang="en">Living and lifestyle</Description>  <Property FormalName="WhyPresent" Value="Classifier"/>  </Topic>  <Topic Duid="ts_12">  <TopicType FormalName="POLITICS"/>  <FormalName Scheme="N2000">POL</FormalName>  <FormalName Scheme="IPTCSubjectCodes">11000000</FormalName>  <Description xml:lang="en">Domestic Politics</Description>  <Property FormalName="WhyPresent" Value="Classifier"/>  </Topic>  <Topic Duid="ts_13">  <TopicType FormalName="Religion"/>  <FormalName Scheme="N2000">REL</FormalName>  <FormalName Scheme="IPTCSubjectCodes">12000000</FormalName>  <Description xml:lang="en">Religion and belief (extend definition)</Description>  <Property FormalName="WhyPresent" Value="Classifier"/>  </Topic>  <Topic Duid="ts_14">  <TopicType FormalName="CategoryCode"/>  <FormalName Scheme="MediaCategory">OVR</FormalName>  <Description xml:lang="en">General news stories</Description>  <Property FormalName="WhyPresent" Value="Classifier"/>  </Topic>  </TopicSet>
            <Role FormalName="Main"/>
                    <Party FormalName="Reuters"/>
                    <Party FormalName="Reuters"/>
                <Property FormalName="SourceFeed" Value="IDS"/>
                <Property FormalName="IDSPublisher" Value=""/>
            <!--Single "Main Text" inner NewsComponent-->
            <NewsComponent EquivalentsList="no" Essential="no" Duid="MTFH09658_2002-07-03_01-40-47_2640656_MAIN_TEXT_NC" xml:lang="en">
                <Role FormalName="Main Text"/>
                    <HeadLine>FEATURE-Afghan villagers rebuild homes from the rubble</HeadLine>
                    <DateLine>July 3, 2002</DateLine>
                    <CopyrightLine>© Reuters 2002. All rights reserved. Republication or redistribution of Reuters content, including by caching, framing or similar means, is expressly prohibited without the prior written consent of Reuters. Reuters and the Reuters sphere logo are registered trademarks and trademarks of the Reuters group of companies around the world.</CopyrightLine>
                    <SlugLine>AFGHAN-RETURNEES (GENERAL FEATURE)</SlugLine>
                        <NewsLineType FormalName="Caption"/>
                        <NewsLineText>AFGHAN-RETURNEES (GENERAL FEATURE):FEATURE-Afghan villagers rebuild homes from the rubble</NewsLineText>
                    <Language FormalName="en"/>
                    <OfInterestTo FormalName="G"/>
                    <OfInterestTo FormalName="RBN"/>
                    <OfInterestTo FormalName="AFA"/>
                    <OfInterestTo FormalName="CSA"/>
                    <OfInterestTo FormalName="LBY"/>
                    <OfInterestTo FormalName="RWSA"/>
                    <OfInterestTo FormalName="RWS"/>
                    <OfInterestTo FormalName="REULB"/>
                    <OfInterestTo FormalName="GNS"/>
                    <OfInterestTo FormalName="SNS"/>
                    <OfInterestTo FormalName="SNI"/>
                    <OfInterestTo FormalName="RNP"/>
                    <OfInterestTo FormalName="DNP"/>
                    <OfInterestTo FormalName="PGE"/>
                    <OfInterestTo FormalName="SXNA"/>
                    <TopicOccurrence Importance="High" Topic="#ts_1"/>
                    <TopicOccurrence Importance="High" Topic="#ts_2"/>
                    <TopicOccurrence Importance="High" Topic="#ts_3"/>
                    <TopicOccurrence Importance="High" Topic="#ts_4"/>
                    <TopicOccurrence Importance="High" Topic="#ts_5"/>
                    <TopicOccurrence Importance="High" Topic="#ts_6"/>
                    <TopicOccurrence Importance="High" Topic="#ts_7"/>
                    <TopicOccurrence Importance="High" Topic="#ts_8"/>
                    <TopicOccurrence Importance="High" Topic="#ts_9"/>
                    <TopicOccurrence Importance="High" Topic="#ts_10"/>
                    <TopicOccurrence Importance="High" Topic="#ts_11"/>
                    <TopicOccurrence Importance="High" Topic="#ts_12"/>
                    <TopicOccurrence Importance="High" Topic="#ts_13"/>
                    <TopicOccurrence Importance="High" Topic="#ts_14"/>
                <ContentItem Duid="MTFH09658_2002-07-03_01-40-47_2640656_MAIN1_TEXT_CI">
                    <MediaType FormalName="Text"/>
                    <Format FormalName="XHTML"/>
                        <Property FormalName="ContentID" Value=""/>
                        <Property FormalName="ContentCreationDateAndTime" Value="20020703T014047+0000"/>
                        <Property FormalName="USN" Value="2640656"/>
                        <Property FormalName="Creator" Value="RTR_JANUS 2.300"/>
                        <html xmlns="">
                                <p> By Denise Duclaux</p>
                                <p> QARBAGH BAZAAR, Afghanistan, July 3 (Reuters) - Hundreds of  Afghan families live in the dust of crumbled, baked mud homes  in Qarbagh Bazaar, struggling to eke out a living in their  devastated village after four years as refugees in neighbouring  Pakistan.</p>
                                <p> "Everything in our life was here, but we walked away," says  the village leader, Dormad, as he watches U.S. soldiers unload  an army truck packed with boxes of clothes and school supplies.</p>
                                <p> The villagers fled their homes last year, some on foot and  a lucky few by car, as fighting between the ruling Taliban and  the opposition Northern Alliance grew bloodier each day.</p>
                                <p> The men, women and children of Qarbagh Bazaar lived under  trees in Pakistan and barely ate for months until aid  organisations gave them tents and sacks of wheat.</p>
                                <p> "A lot of people left here, it was so crowded on the  roads," Dormad said, speaking through a translator. "We had  nothing."</p>
                                <p> The villagers began straggling back, family by family, in  December after the Northern Alliance ousted the Taliban with  American help.</p>
                                <p> Dormad says the fundamentalist Islamic Taliban imprisoned  and tortured many of the village men during its five-year rule.</p>
                                <p> "When the first villagers arrived (back) they were sad,  because there was nothing left," said Dormad, whose village  stood near the frontline between Taliban and Northern Alliance  fighters. "But then they are happy, because the Taliban were  gone and they are hopeful that everything will be okay."</p>
                                <p> Dormad and his villagers still hold fast to the hope of a  better life, but the path ahead is daunting. The villagers are  jobless as Afghanistan struggles to climb out of the shadow of  more than two decades of war, and their fields are barren after  irrigation systems collapsed under years of neglect.</p>
                                <p> DISTANT DREAMS</p>
                                <p> Running water, electricity and health care are distant  dreams. "We are jobless, without enough food and water," Dormad  said. "We need help."</p>
                                <p> Dormad is pinning his hopes on U.S.-led coalition forces  and non-governmental organisations (NGOs) to help rescue  Qarbagh Bazaar from the clutch of poverty.</p>
                                <p> Soldiers from Bagram Air Base, the staging post for the  coalition forces in Afghanistan, are visiting his village for  the fifth time since the Taliban fell late last year.</p>
                                <p> Soldiers and villagers lug boxes off the army truck,  plunking each down in a small cloud of dust. Winter clothes,  school supplies, sneakers and sheets of plywood form a growing  pile of hope for the villagers.</p>
                                <p> "The distribution is up to you. I just ask that you please  don't sell it," said Major Bryan Cole to Dormad, knowing the  lure of hard cash in this poverty-stricken country.</p>
                                <p> The soldiers and their gifts attract a crowd of men, boys  and brightly dressed girls. Women stay hidden behind the worn  walls of their homes, save for a few huddled yards away beneath  bright blue burqas.</p>
                                <p> The children show little interest in the unopened boxes,  but beg the visitors for pens with the scraps of English they  have learned over the months. "How are you, give me pen," they  chant as they tug on arms and trouser legs.</p>
                                <p> Drawing and writing are a treat for the children, some of  whom have ragged scars on their faces and badly swollen eyes.</p>
                                <p> U.S. bombs levelled the village school, which the American  military said the Taliban had been using as a hideout.</p>
                                <p> The new school is housed in two tents that hold seven  classes a day for different age groups. The teachers, who are  paid nothing, offer classes in maths, history, the Holy Koran  and local languages like Persian and Pashto.</p>
                                <p> DEMINING</p>
                                <p> The children must be careful where they play, for while  some patches of ground are safe, others are deadly. A  mysterious garble of letters and numbers -- HTNO10BAG -- is  spray-painted in white on the walls of village buildings,  ravaged by decades of fierce winds and relentless war.</p>
                                <p> Halo Trust's Unit No. 10 out of Bagram has demined the  area, and the NGO has left its all-clear mark for villagers  looking to resettle and soldiers keeping up their patrol.</p>
                                <p> The U.S. military has helped to dig a new well for Qarbagh  Bazaar. It also plans to build another school for the children  and hopes to help with supplies until next year's growing  season.</p>
                                <p> Worry has replaced the terror that plagued villagers during  the years of civil war, but Dormad said the people of Qarbagh  Bazaar are far from defeated.</p>
                                <p> "It is a hard, hard life," he said. "But it is better than  being in other places like Pakistan. This is our home."  </p>

Open in new window

Who is Participating?

Improve company productivity with a Business Account.Sign Up

Mark WillsConnect With a Mentor Topic AdvisorCommented:
Frustrating, I know... There has been a couple of views, and I think more than one is monitoring.

If you want to process the file via SQL, then I might be able to help. Can you show the database table that is receiving the data ? Do all tags have to be processed - or just a few identifiers plus the body ? Can the server see the file - or can you call a stored procedure passing the document (content) as a string (ie stored procedure will use an XML datatype to receive - it does have a 2 gig limit) ?
Sreejith22Author Commented:
Thanks mark,
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.