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 10498
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_P LEASEtkachenko. com> wrote in message
news:eJ******** ******@TK2MSFTN GP12.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.Document Element.ChildNo des
If xmlnode.Attribu tes("Name").Val ue = "TEST2" Then
xmldoc.Document Element.RemoveC hild(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******@onlin e.microsoft.com > wrote in message
news:H4******** ******@cpmsftng xa06.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.Document Element.ChildNo des
If xmlnode.Attribu tes("Name").Val ue = "TEST2" Then xmldoc.Document Element.RemoveC hild(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>Tru e</Location>
thanks for your help
Gerry
"MSFT" <lu******@onlin e.microsoft.com > wrote in message
news:H4******** ******@cpmsftng xa06.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.Document Element.ChildNo des
If xmlnode.Attribu tes("Name").Val ue = "TEST2" Then xmldoc.Document Element.RemoveC hild(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_P LEASEtkachenko. com> wrote in message
news:Od******** ******@TK2MSFTN GP12.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.e du> wrote in message
news:%2******** ********@TK2MSF TNGP11.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_P LEASEtkachenko. com> wrote in message news:Od******** ******@TK2MSFTN GP12.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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:TMSWebServices">
All attributes are removed EXCEPT
|
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 and its length,
that can impact the performance of an XML parser?
The bulk of our XML parsing uses the latest and greatest version of
Apache Xerces.
|
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" attribute2="value2" ... />
...
|
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 schema for it with Visual Studio, I get the error
"Failed to create a schema for this data file because:
|
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"
xsi:schemaLocation="urn:/ows/aws/1.2
http://www.overture.com/schema/dtc/1.2/dtc_response.xsd"
xmlns="urn:/ows/aws/1.2" success="true">
<ActionsResponse accountId="123">
<GetAccountIdsResponse success="true">
<Account id="123" market="UK" />
....
| |
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 server tables programmatically. The web service builds and
deploys with no problems. When I try to add the corresponding Web
Reference to the Web Site project I get the error listed below.
I am able to create other Web Services on the same server...
|
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 is in. I want to avoid making the
user have to submit the form's id if possible.
Let me know if my question is unclear...thanks!
Kel
|
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 attribute xml:lang="EN" in some elements which should not be there. I am enclosing the code for reference.
I used to remove the occurences manually...but now I need an assembly which can do that for me in C#.I have to remove the occurences of the word...
|
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'
attr2='somevalue' attrN='...'>markup</span>"
3 Dim objSpan As HTMLSpanElement =
browser.Document.createElement("span")
4 objSpan.innerHTML = strMarkup
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |