SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Jul 23, 2009, 05:24 #1
- Join Date
- Jul 2009
- Posts
- 2
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Removing all nodes based on attribute
Hi
New to these forums, hope you can help, my XML programming experience is minimal so still struggling with some of the concepts and best approaches.
I have an XMLdocument which has many child nodes.
There is an attribute on some nodes, "Deleted".
I need to parse my XMLDocument
I want to remove all nodes and children which have this "Deleted" attribute.
Cannot show code example, forum wont let me as new member
Any help appreciated, thanks
-
Aug 2, 2009, 05:45 #2
- Join Date
- Aug 2009
- Location
- Bavaria, Germany
- Posts
- 106
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It'd be helpful if you tell us, what programming language should do the thing you want to do.
If you want to do that in PHP, search for DomDocument or another XML parser, shouldn't be that difficult to identifiy tags with a specified attribute.
Any other language should have an analog way of identifiying tags/attributes/whateveryoulike...
-
Aug 3, 2009, 02:51 #3
- Join Date
- Jul 2009
- Posts
- 2
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
That would have helped, sorry.
It was in VB.NET
I eventually, through trial and error, worked out how to do it. Probably not the most efficient way but it worked.
Code:bMore = true do oNode = oDocClone.DocumentElement.SelectSingleNode("//*[@Deleted='1']") if not IsNothing(oNode) then oNode.ParentNode.RemoveChild(oNode) else bMore = False end if loop while bMore
Bookmarks