Hi all,
The following is part of XML file, how do I search through the file and remove an
Element and all it's attributes. Example: TEST2? Of course I will pass the Element Name to remove
from a control.
- <Forms>
- <Form Name="TEST1">
<Width>600</Width>
<Height>400</Height>
<Tag>2-1</Tag>
</Form>
<Form Name="TEST2">
<Width>200</Width>
<Height>26</Height>
<Tag>2-3</Tag>
</Form>
<Form Name="TEST3">
<Width>300</Width>
<Height>45</Height>
<Tag>2-4</Tag>
</Form>
</Forms>
To look like this?
<Forms>
- <Form Name="TEST1">
<Width>600</Width>
<Height>400</Height>
<Tag>2-1</Tag>
</Form>
<Form Name="TEST3">
<Width>300</Width>
<Height>45</Height>
<Tag>2-4</Tag>
</Form>
</Forms>
Thanks
Gerry 8 10472
Gerry Viator wrote: The following is part of XML file, how do I search through the file and remove an Element and all it's attributes. Example: TEST2? Of course I will pass the Element Name to remove from a control.
DOM solution - load document into XmlDocument, locate the element and
remove it.
XSLT solution - identity transfomation + custom template for Form element.
XmlReader solution - read till the element, skip till EndElement and
continue.
Which one do you prefer?
--
Oleg Tkachenko http://www.tkachenko.com/blog
Multiconn Technologies, Israel
DOM solution - load document into XmlDocument, locate the element and
remove it
This would be fine. Thanks
Gerry
"Oleg Tkachenko" <oleg@NO_SPAM_PLEASEtkachenko.com> wrote in message
news:eJ**************@TK2MSFTNGP12.phx.gbl... Gerry Viator wrote:
The following is part of XML file, how do I search through the file and remove an Element and all it's attributes. Example: TEST2? Of course I will pass the Element Name to remove from a control.
DOM solution - load document into XmlDocument, locate the element and remove it. XSLT solution - identity transfomation + custom template for Form element. XmlReader solution - read till the element, skip till EndElement and continue. Which one do you prefer? -- Oleg Tkachenko http://www.tkachenko.com/blog Multiconn Technologies, Israel
Thank for Oleg's Idea. I attach some sample code as the supply to his post:
Dim xmldoc As New XmlDocument
xmldoc.Load("c:\edit1.xml")
Dim xmlnode As XmlNode
For Each xmlnode In xmldoc.DocumentElement.ChildNodes
If xmlnode.Attributes("Name").Value = "TEST2" Then
xmldoc.DocumentElement.RemoveChild(xmlnode)
End If
Next
xmldoc.Save("c:\edit2.xml")
Gerry, Hope this answer your question.
Luke
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Thanks everyone,
Gerry
"MSFT" <lu******@online.microsoft.com> wrote in message
news:H4**************@cpmsftngxa06.phx.gbl... Thank for Oleg's Idea. I attach some sample code as the supply to his
post: Dim xmldoc As New XmlDocument
xmldoc.Load("c:\edit1.xml")
Dim xmlnode As XmlNode
For Each xmlnode In xmldoc.DocumentElement.ChildNodes
If xmlnode.Attributes("Name").Value = "TEST2" Then xmldoc.DocumentElement.RemoveChild(xmlnode)
End If Next
xmldoc.Save("c:\edit2.xml")
Gerry, Hope this answer your question.
Luke Microsoft Online Support
Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
Thanks again,
What if I wanted to change the value below of TEST2?
<Width>300</Width>
to 350?
and add this to TEST2?
<Location>True</Location>
thanks for your help
Gerry
"MSFT" <lu******@online.microsoft.com> wrote in message
news:H4**************@cpmsftngxa06.phx.gbl... Thank for Oleg's Idea. I attach some sample code as the supply to his
post: Dim xmldoc As New XmlDocument
xmldoc.Load("c:\edit1.xml")
Dim xmlnode As XmlNode
For Each xmlnode In xmldoc.DocumentElement.ChildNodes
If xmlnode.Attributes("Name").Value = "TEST2" Then xmldoc.DocumentElement.RemoveChild(xmlnode)
End If Next
xmldoc.Save("c:\edit2.xml")
Gerry, Hope this answer your question.
Luke Microsoft Online Support
Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
Thanks for links,
I also wish Microsoft would make there HELP much better then it is.
On line and within VS.NET. I always search first, but get
frustrated with not findings what I'm looking for.
Microsofts Help can be made alot better. I do beleive they are going to make
major changes to it from what I hear.
Thanks
Gerry
"Oleg Tkachenko" <oleg@NO_SPAM_PLEASEtkachenko.com> wrote in message
news:Od**************@TK2MSFTNGP12.phx.gbl... Gerry Viator wrote:
What if I wanted to change the value below of TEST2?
<Width>300</Width>
to 350?
and add this to TEST2? Gerry, to avoid asking such simple questions learn about using XmlDocument class, e.g. "Modifying Nodes, Content, and Values in an XML Document" [1] "Inserting Nodes into an XML Document" [2] "Select Nodes Using XPath Navigation" [3]
[1] http://msdn.microsoft.com/library/en...mldocument.asp [2] http://msdn.microsoft.com/library/en...mldocument.asp [3] http://msdn.microsoft.com/library/en...navigation.asp -- Oleg Tkachenko http://www.tkachenko.com/blog Multiconn Technologies, Israel
This stuff should be in the framework sdk.
ice
"Gerry Viator" <vi*****@musc.edu> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... Thanks for links,
I also wish Microsoft would make there HELP much better then it is. On line and within VS.NET. I always search first, but get frustrated with not findings what I'm looking for.
Microsofts Help can be made alot better. I do beleive they are going to
make major changes to it from what I hear.
Thanks Gerry
"Oleg Tkachenko" <oleg@NO_SPAM_PLEASEtkachenko.com> wrote in message news:Od**************@TK2MSFTNGP12.phx.gbl... Gerry Viator wrote:
What if I wanted to change the value below of TEST2?
<Width>300</Width>
to 350?
and add this to TEST2?
Gerry, to avoid asking such simple questions learn about using
XmlDocument class, e.g. "Modifying Nodes, Content, and Values in an XML Document" [1] "Inserting Nodes into an XML Document" [2] "Select Nodes Using XPath Navigation" [3]
[1] http://msdn.microsoft.com/library/en...mldocument.asp [2] http://msdn.microsoft.com/library/en...mldocument.asp [3] http://msdn.microsoft.com/library/en...navigation.asp -- Oleg Tkachenko http://www.tkachenko.com/blog Multiconn Technologies, Israel
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: sam.stamport |
last post by:
Hello,
In my C# program I execute an attributes remove to remove all
attributes in the following root node.
<xtvd xmlns:xsd="http://www.w3.org/2001/XMLSchema"...
|
by: Tom Kerigan |
last post by:
I know that longer element names increase the size of an XML document,
ultimately resulting in a larger amount of data at parse-time. Is there
anything else, specifically related to an element name...
|
by: Tod Johnson |
last post by:
Hello all,
Can't figure it out. :( Assume that we have 2 XML document:
Document1 (source):
<elements>
<elementA attribute1="value1" attribute2="value2" ... />
<elementA attribute1="value1"...
|
by: Martin |
last post by:
Hi,
I have a xml file like the one below
<?xml version="1.0" encoding="utf-8"?><e1
xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2"
e1:rest="345"/>
If I try to create a...
|
by: fizzy |
last post by:
i am fetching an xml document with the following structure:
<?xml version="1.0" encoding="UTF-8"?>
<DTCResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"...
|
by: namewitheldbyrequest |
last post by:
"The XML element 'EnableTheming' from namespace 'http://tempuri.org/'
is
already present in the current scope"
I created a Web Service: I imported System.Data.SqlClient so I could
access SQL...
|
by: kelvin.jones |
last post by:
Hi, if I had the ID of an input element, how can I find the input's
FORM in javascript?
Basically, given a input's dom id, I want to insert something in the
onSubmit of the Form that that input...
|
by: kasala |
last post by:
I get an xml document as input from other department. The input xml document i recieve has a particular word "rnx" which should not be there and my system doesn't support it. And there is also...
|
by: cloftis |
last post by:
Using VS2003, VB and MSHTML,
Using an HTMLSpanElement I want to enumerate the attributes of a SPAN
tag.
1 'For testing sake
2 Dim strMarkup as String = "<span attr1='somevalue'...
|
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...
|
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...
|
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: 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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
| |