Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / April 2006

Tip: Looking for answers? Try searching our database.

Add XMLNodeList to new XMLDocument

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GCeaser@aol.com - 21 Apr 2006 16:38 GMT
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/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.