Merging XMLTextReaders in C#

Posted by smithchelluk on Stack Overflow See other posts from Stack Overflow or by smithchelluk
Published on 2009-09-28T10:09:22Z Indexed on 2010/03/26 17:03 UTC
Read the original article Hit count: 137

Filed under:
|
|

I have a website that needs to pull information from two diffferent XML data sources. Originally I only need to get the data from one source so I was building a URL in the backend that went and retrieved the data from the XML site and then parsed and rendered it in the front end of the website.

Now I have to use a 2nd data source and merge the result sets (which are identically structured XML) into one result set.

Here is the code I am currently using to get one XML feed.

sUrl = sbUrl.ToString(); //The URL for the XML feed

    XmlDocument xDoc = new XmlDocument();

    StringBuilder oBuilder = new StringBuilder(); //The parsed HTML output

    XmlTextReader oXmlReader = new XmlTextReader(sUrl);
    oXmlReader.Read();
    xDoc.Load(oXmlReader);


     XmlNodeList List = xDoc.GetElementsByTagName("result");
    foreach (XmlNode node in List)
    {
        XmlElement key = (XmlElement)node;
        //BUILD THE OUTPUT HERE


    }

Thanks in advance for your help.

© Stack Overflow or respective owner

Related posts about c#

Related posts about xmltextreader