473,320 Members | 1,839 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,320 software developers and data experts.

With an XmlNode from a NodeList Can you tell where you are in the original XmlDocument

This problem was raised in another post

Assuming we have an XmlDocument (xDoc) that has a node (<dickster>)
randomly dispersed throughout the hierarchy.

eg
<root>
<A>
<B>
<C>
<dickster>1</dickster>
</C>
</B>
</A>
<D>
<dickster>2</dickster>
</D>
<E>
<F>
<dickster>3</dickster>
<dickster>4</dickster>
</F>
</E>
<dickster>5</dickster>
</root>
We use SelectNodes to get an XmlNodeList that mathces xpath
"//dickster"

In the problem on the other post we wanted to embed all dickster
elements in say a <temp> element

i.e.
<root>
<A>
<B>
<C>
<temp>
<dickster>1</dickster>
</temp>
</C>
</B>
</A>
<D>
<temp>
<dickster>2</dickster>
</temp>
</D>
<E>
<F>
<temp>
<dickster>3</dickster>
</temp>
<temp>
<dickster>4</dickster>
</temp>
</F>
</E>
<temp>
<dickster>5</dickster>
</temp>
</root>
How can we tell where we are in the xDoc hierarchy when we are looping
through each of the nodes in the XmlNodeList
i.e.

Dim xDoc As XmlDocument
xdoc.load(<xml>)
Dim xList As XmlNodeList = xDoc.SelectNodes("//dickster")
Dim xnode as XmlNode

For each xnode in xList
' how can xnode tell where it belongs in the xml hierarchy ???
Next
I hope this makes sense.

Original issue was raised here:
groups.google.com/group/microsoft.public.dotnet.xml/browse_thread/thread/bab743a6aab8b84d
Dickster

Mar 24 '06 #1
1 1009
Maybe this makes it a bit clearer:

For Each xNode In xList
Dim xEle As XmlElement = xDoc.CreateElement("temp")
xEle.AppendChild(xNode)

' now I want to replace xNode by xEle but I
' dont know how to do that because i dont know where I
' am in xDoc in order to use .ReplaceChild()
Next

Mar 24 '06 #2

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

Similar topics

5
by: David Costelloe | last post by:
Hi, I am having trouble with this code can't seem to load these email values any Ideas? XML File <?xml version="1.0" ?> <Sections> <FilePath> <Path>c:\temp\</Path> </FilePath>
2
by: Arthur Dzhelali | last post by:
I have a two xml files schema is identical. When I read file into dataset and then bind dataset to the form. These are weather files we are getting from weather service. One file has only...
4
by: Gismo | last post by:
I have got file raport.rld which is an XML file generated by MS Reporting Services. The problem is: in this file are tags from two different namespaces ...
1
by: Emsi | last post by:
Hello, how can I read values of child nodes with the XmlTextReader? File format: <root> <items> <item> <field1>value1</field1> <field2>value2</field2>
1
by: Hans [DiaGraphIT] | last post by:
Hi! I have problem with passing data to custom action. I don't know what wrong I'm doing. I'm trying to follow the steps in the walkthrough: "Passing Data to a Custom Action" ...
1
by: Christian Rühl | last post by:
hey! what i wanna do sounds very simple at first, but it turned out to be a real bone crusher... i want to check if a treeView node is checked and if a correspondent node in my xml config file...
1
by: Demorsy | last post by:
Disappointed, this is not the first time I'm posting this kind of a request for help, but no helpful answer was posted yet. I'll try make my question as clear as I can: (1) I wish to write an...
1
by: Darsin | last post by:
What i am doing is to pull the data from a CMS and import it to Word 2007 Beta and i also have to export the data from Word 2007 Beta back to that CMS. We have with us two Web Services of the CMS....
4
by: =?Utf-8?B?Q2Fpcm4=?= | last post by:
I am new to Xpath but wish to parse an XML document for nodes which contain a child node with a particuale value. Please does anybody have any clues as to why I never get any returns in the root...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.