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

Need a few examples

It's been awhile since I've had to work with XML in VB.Net. Look at the
following snippet:

<Parameters>
<Parameter>123</Parameter>
<Parameter>456</Parameter>
</Parameters>

How do I find Parameter=123 and delete it?
How do I delete all children of <Parameters>?

Assume I read this XML in from a file and wish to write the results of my
changes out to a different file. Is this simpler to do in .Net 2.0 than in
..Net 1.5?

Even if specific examples aren't available, .net's handling of XML is quite
overwhelming: DOM, XPATH, ADO.NET-->relational???

Thanks,

Billg_SD
Jan 11 '06 #1
1 1068


Billg_sd wrote:

<Parameters>
<Parameter>123</Parameter>
<Parameter>456</Parameter>
</Parameters>

How do I find Parameter=123 and delete it?
Dim Xml_Document As XmlDocument = New XmlDocument
Xml_Document.PreserveWhitespace = True
Xml_Document.Load(Args(0))

Dim Parameter As XmlNode =
Xml_Document.SelectSingleNode("Parameters/Parameter[. = 123]")
If Not Parameter Is Nothing Then
Parameter.ParentNode.RemoveChild(Parameter)
End If

Xml_Document.Save(Console.Out)

Of course instead of doing Save(Console.Out) you could also save to some
file.
How do I delete all children of <Parameters>?

Dim Xml_Document As XmlDocument = New XmlDocument
Xml_Document.PreserveWhitespace = True
Xml_Document.Load(Args(0))

Dim Parameters As XmlNodeList =
Xml_Document.SelectNodes("Parameters/node()")

For Each Child As XmlNode In Parameters
Child.ParentNode.RemoveChild(Child)
Next

Xml_Document.Save(Console.Out)
Assume I read this XML in from a file and wish to write the results of my
changes out to a different file. Is this simpler to do in .Net 2.0 than in
.Net 1.5?


There is no .NET 1.5, but saving to a file is as simple as
Xml_Document.Save("file.xml")
whether you use .NET 1.x or .NET 2.0.
There haven't been any major changes in System.Xml or
System.Xml.XmlDocument when it comes to loading and saving.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jan 11 '06 #2

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

Similar topics

4
by: Marc | last post by:
Hi all, I am trying to write an application where I need the ability to open an Excel spreadsheet and do basic read/write, insert rows, and hide/unhide rows. Using win32com I have been able to...
8
by: Radioactive Man | last post by:
I am fairly new to the latest verion of Python and using it on windows 95, 2000, and/or XP. What libraries, modules, functions, etc. would I need to set up a Python script to download a file, say...
5
by: Mike Judkins | last post by:
I'm looking for examples of websites (preferably large and well known companies, not personal sites or developer-to-developer sites) that use XML and XSLT as a technology platform from which to...
3
by: Donald Firesmith | last post by:
How do I use XSL to generate and XHTML list of hyperlinks stored in XML? My XML contains links of examples of the form: <examples> <example> <link url="aURL">some text</link> <info>some more...
1
by: Richard Hollenbeck | last post by:
Hello Newsgroup. You have all been very helpful in the past and I thank you. I try to ask relevant questions so that they don't just benefit me, but also benefit the group. I'm currently...
11
by: Larry | last post by:
I will be teaching an eCommerce application development course using ASP.Net after many years of having taught classic ASP. (Course was interrupted by 18 months in the Middle East with my Army...
1
by: skootr | last post by:
Has anyone seen any COMPLETE bound form examples? By complete, I mean a form that has Add/Edit/Delete capabilities. Every example I've seen on the 'net, in books, and in the VB.Net Resource Kit...
1
by: Tyno Gendo | last post by:
Hi everyone I need to move on a step in my PHP... I know what classes are, both in PHP4 and 5 and I'm aware of "patterns" existing, but what I'm looking for are some real world projects eg....
0
by: noway001 | last post by:
Hi, I need to learn how to do unit tests for certain functions. I have googled and come accross some stuff, but all the examples are easy. I read multiple articles on code project, but it didn't...
2
by: jasiu85 | last post by:
Hey, Please take a look at the code of the two threads below: COMMON_DICT = {} def thread_1(): global COMMON_DICT local_dict = prepare_dict() COMMON_DICT = local_dict
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.