473,326 Members | 2,732 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,326 software developers and data experts.

XML Node ?

Good morning,

I have the folowing XML data in a file;
<code>

<?xml version="1.0" encoding="utf-8"?>
<Photos>
<GotTogetoffThisComment>@ 2/21/2005 10:01:14 AM Visitor{IP}: 127.0.0.1
left;
She Dances good
</GotTogetoffThisComment>
<JudgeDreddComment>@ 2/21/2005 10:25:12 AM Visitor{IP}: 127.0.0.1 left;
The future Cop
</JudgeDreddComment>
<SheDancesComment>@ 2/21/2005 10:50:28 AM Visitor{IP}: 127.0.0.1 left;
Shes dances for the hutt
</SheDancesComment>
</Photos>

</code>

In VB.net how would I find the node, JudgeDreddComment, and delete it from
the file ?

Please help as this is driving me nuts.

Thanks

--
Deasun
Home Site: www.tirnaog.com
Check out: The Code Vault in my forums section.
Nov 19 '05 #1
3 1543
I'm not going to attempt writng VB.NET as I'm a C# guy.
This is how I would do it in C#, it should be easy to port it to VB.NET
XmlDocument doc = new XmlDocument();
doc.Load(filename);

XmlNode nodeToRemove = null;

foreach(XmlNode node in doc.DocumentElement.ChildNodes)
{
if(node.Name == "JudgeDreadComment")
{
nodeToRemove = node;
break;
}
}

// remove node outside loop
// then we are sure that we don't change the collection we are itterating
over
if(nodeToRemove != null)
{
doc.DocumentElement.RemoveChild(nodeToRemove);
}
Chris

"Deasun" <De****@discussions.microsoft.com> wrote in message
news:70**********************************@microsof t.com...
Good morning,

I have the folowing XML data in a file;
<code>

<?xml version="1.0" encoding="utf-8"?>
<Photos>
<GotTogetoffThisComment>@ 2/21/2005 10:01:14 AM Visitor{IP}: 127.0.0.1
left;
She Dances good
</GotTogetoffThisComment>
<JudgeDreddComment>@ 2/21/2005 10:25:12 AM Visitor{IP}: 127.0.0.1 left;
The future Cop
</JudgeDreddComment>
<SheDancesComment>@ 2/21/2005 10:50:28 AM Visitor{IP}: 127.0.0.1 left;
Shes dances for the hutt
</SheDancesComment>
</Photos>

</code>

In VB.net how would I find the node, JudgeDreddComment, and delete it from
the file ?

Please help as this is driving me nuts.

Thanks

--
Deasun
Home Site: www.tirnaog.com
Check out: The Code Vault in my forums section.

Nov 19 '05 #2
Or use XPath, which would look something along these lines:

(C#)
XmlNodeList nodes = doc.SelectNodes("//Photos/JudgeDreddComment");

---
http://wilcoding.xs4all.nl

Nov 19 '05 #3
Thanks guys got the anwser.
Used the removechild() to get rid of it.

If anyone is interested in seeing what I cam up with you can find it on my
site in the Code Vault area unde VB.net, XML - How to delete a Node from the
file

Thanks again for your pointers.

Deasun
http://www.tirnaog.com

"Deasun" wrote:
Good morning,

I have the folowing XML data in a file;
<code>

<?xml version="1.0" encoding="utf-8"?>
<Photos>
<GotTogetoffThisComment>@ 2/21/2005 10:01:14 AM Visitor{IP}: 127.0.0.1
left;
She Dances good
</GotTogetoffThisComment>
<JudgeDreddComment>@ 2/21/2005 10:25:12 AM Visitor{IP}: 127.0.0.1 left;
The future Cop
</JudgeDreddComment>
<SheDancesComment>@ 2/21/2005 10:50:28 AM Visitor{IP}: 127.0.0.1 left;
Shes dances for the hutt
</SheDancesComment>
</Photos>

</code>

In VB.net how would I find the node, JudgeDreddComment, and delete it from
the file ?

Please help as this is driving me nuts.

Thanks

--
Deasun
Home Site: www.tirnaog.com
Check out: The Code Vault in my forums section.

Nov 19 '05 #4

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

Similar topics

8
by: J Peterman | last post by:
Im having a nightmare trying to understand these nodes and linked lists. I've posted my code for my node.h, node.cpp, linkedlist.h and linkedlist.cpp files in separates replies. Can someone...
2
by: Ralf Wahner | last post by:
Dear Masters of XSLT Could I ask you for a clue on the following question? I'd like to use XSLT to transform an XML source file to LaTeX. In the following small example the <para> Element...
6
by: Chuck | last post by:
What's the difference between using "catalog node" and catalog admin node"? -- Chuck Remove "_nospam" to reply by email
3
by: stabbert | last post by:
We are running DB2 UDB 8.1.6 in a partitioned environment where we have 8 physical nodes. We have a process that remotely connects to each individual node and loads some data. By setting the...
5
by: Jeroen Ceuppens | last post by:
I need to put a new node at the end of the tree, that end is not te lowest in de list but the deepest (the one with the most + before it) Node A Node 1 Node 2 Node 3 Node 4: Deepest Node B:...
3
by: Saradhi | last post by:
Hi All, Here I am facing a performance problem with the TreeView Node renaming. I am displaying a hierarchy Data in a treeview in my Windows C# Application. My tree view represents an...
8
by: Dylan Parry | last post by:
Hi folks, I have an XML node called "myNode" and it contains: "This is some text" Now I can use the myNode.nodeValue property to get the string of text above. But say myNode contains: ...
6
by: Derek Hart | last post by:
I bring in an xml file into vb.net by using xmlDoc.LoadXml(XMLString) - I run xpath statements against the xml file to grab data from it, so I use, as an example, //Vehicles/Vehicles/@make to get...
9
by: Moses | last post by:
Hi All, How to check weather a node has sibling? Is there any function like " hasChildNodes() " Thanks in Advance Moses
3
by: Kane | last post by:
When you create node 1 you allocate memory and link it Again when you create node 2 you would allocate memory for that node in a different section of the code. Is there more efficient way where I...
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...
1
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.