Click here to Skip to main content
15,895,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have xml feed from one or more .xml files.

I have to show this feed in jquery scroller, I am using datafile property of xml datasource control for single .xml file,

But now I want to scroll feed from multiple .xml files

how can I merge those multiple xml files and produce single .xml file and set the xml daatasource data file property to this newly produced file..? so that feeds from all .xml files are shown.

any suggestion is appreciated.

presently I am using xmlreader with dataset merging, it's working but I want it done with xslt passing xml file urls as parameters to that .xslt file and making all those as one file, so that I can bind it to the xml datasource.

I am not good at .xslt and that syntax, moreover I have to pass xml feed urls dynamically to the xslt file, all files have same xpath like rss/channel/item blah....

How can I do this dynamically.
Posted

1 solution

There is no one single recipe, it depends on the schema of each file. In some cases, XML can contradict to each other, so such problem may be solvable or not. One simple example is: merging can make unique attribute values (required by the schema of the target file, such as id) non-unique.

There can be different methods of doing it. A trivial approach is parsing all files and then combining them into a DOM document, checking validity, etc. Another method could be forward-only, when you open input files with XmlReader, all at once or one-by-one and using the class XmlWriter for the target file.

Technically, you can refer to my short overview of different XML classes available on .NET FCL:


  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].
  2. Use the classes System.Xml.XmlTextWriter and System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx[^], http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^].
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].


Good luck,
—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900