All,
I have a very large XML document that contains two types of
elements. I want to select all the elements of each type and place
them in separate XML documents.
This is what I have so far:
'Add the Metis namespace so the querys will work
lobj_namespaceManager = New
XmlNamespaceManager(iobj_MetisModel.NameTable)
lobj_namespaceManager.AddNamespace("Troux",
"http://www.metis.no/metis")
'Execute the queries.
iobj_Relationships =
iobj_MetisModel.SelectNodes("//Troux:relationship",
lobj_namespaceManager)
iobj_Objects =
iobj_MetisModel.SelectNodes("//Troux:object", lobj_namespaceManager)
'I Get the correct results from the query
'Create the Relationships XML Document
lobj_WorkXMLDocument = New XmlDocument
lobj_RootElement =
lobj_WorkXMLDocument.CreateNode(XmlNodeType.Element, "root", "")
-----------------------------------------------------------------------------
>From here, is there a way I can add all the nodes in the node list to
the root element of the new XML document WITHOUT have to iterate
through the entire collection? (BTW - I am using VB.net) - Any
assistance would be appreciated.
Martin Honnen - 21 Apr 2006 16:51 GMT
> iobj_Objects =
> iobj_MetisModel.SelectNodes("//Troux:object", lobj_namespaceManager)
> lobj_WorkXMLDocument = New XmlDocument
> lobj_RootElement =
> lobj_WorkXMLDocument.CreateNode(XmlNodeType.Element, "root", "")
>>From here, is there a way I can add all the nodes in the node list to
> the root element of the new XML document WITHOUT have to iterate
> through the entire collection?
No, you have to iterate and import and append each node e.g. *VB pseudo
code)
For Each obj As XmlNode In iobj_Objects
lobj_RootElement.AppendChild(lobj_WorkXMLDocument.ImportNode(obj,
True))
Next

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/