Merging XMLTextReaders in C#
- by smithchelluk
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.