Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Combine multiple XmlDocument(s) [Thread Next] Re: Combine multiple XmlDocument(s)To: NULL Date: 5/5/2007 1:18:00 PM
Craig Buchanan wrote:
> For i As Integer = 1 To XmlDocuments.Count - 1
> 'process the <Entity/> nodes
> For Each child As XmlNode In XmlDocuments(i).DocumentElement.ChildNodes
> 'add node to 1st XmlDocument
> XmlDocuments(0).DocumentElement.AppendChild(XmlDocuments(0).ImportNode(child,
> True))
> Next
> Next
> Is there a more-efficient way to do this?
Storing the DocumentElement in a variable once and then accessing the
variable might perform better then referencing DocumentElement each time
e.g.
Dim root As XmlNode = XmlDocuments(0).DocumentElement
For i As Integer = 1 To XmlDocuments.Count - 1
For Each child As XmlNode In XmlDocuments(i).DocumentElement.ChildNodes
root.AppendChild(XmlDocuments(0).ImportNode(child, True))
Next
Next
> For bonus points, is there a way
> to sort the <Entity/> elements based on an attribute's value?
Sorting is possible with XSLT (i.e. xsl:sort) or with .NET also using
XPathNavigator
<http://msdn2.microsoft.com/en-us/library/system.xml.xpath.xpathexpression.addsort.aspx>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
