473,378 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Add XMLNodeList to new XMLDocument

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.Elemen t, "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.

Apr 21 '06 #1
1 10921


GC*****@aol.com wrote:

iobj_Objects =
iobj_MetisModel.SelectNodes("//Troux:object", lobj_namespaceManager)
lobj_WorkXMLDocument = New XmlDocument
lobj_RootElement =
lobj_WorkXMLDocument.CreateNode(XmlNodeType.Elemen t, "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

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Apr 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Roe | last post by:
Hi! Here's my code: //xd is an XmlDocument object, xnm is an XmlNameSpaceManager XmlNodeList xnl = xd.SelectNodes ("/bd:SubscriptionInfoSet/bd:SubscriptionInfo",xnm); //TEST: Check to see...
1
by: Martin Honnen | last post by:
With both .NET 1.0 and 1.1 I have found the following strange behaviour where System.Xml.XmlDocument.LoadXml doesn't throw an error when parsing a text node with a character reference to an invalid...
1
by: Robert | last post by:
I am having a problem selecting nodes using the XMLnodelist Selectnodes using XPATH when I use XML SPY is successfully queries but when is use VB.net it comes up with nothing. Here is my code ...
1
by: Randal Chapman | last post by:
Hi. I am returning a "distinct" list of nodes from an xmldocument using selectnodes. I get the list fine, and I can select individual nodes, but when I try to access the count of the list my...
1
by: Peter Nofelt | last post by:
Hey All, I'm running into this issue with parsing through an xml document by tag name. Below is an example xml document: File Name: things.xml <things> <people> <name>Peter</name>
3
by: Maurice Cosgrave | last post by:
Hi, I was wondering if there was a way to move values from an array into an XmlNodeList? I have the values loaded into a string array from a previous point in the application; now I need to...
4
by: SkyHook | last post by:
1. Under the topic "Select Nodes Using XPath Navigation" it says: "All XmlNodeList objects are synchronized with the underlying document, therefore if you ... modify the value of a node, that node...
1
by: bigeddie | last post by:
Hi, I'm trying to get an instance off a XmlNodeList without using selectNodes(...) XmlNodeList test1 = new XmlNodeList(); (C#) but that doesn't work. What's my mistake?
4
by: eggie5 | last post by:
Hi, I have an XmlNodeList and I need to reverse it. Just like Array.Reverse(), but it has to stay as an XmlNodeList. Any ideas?
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.