2007-07-03

Read xml content by XmlDocument

This sample show, How to read xml content by use XmlDocument namespace.

You can see this link for xml sample content.

Sample Code


Dim m_xmld As XmlDocument
Dim m_nodelist As XmlNodeList
Dim m_node As XmlNode

'Create the XML Document
m_xmld = New XmlDocument()

'Load the Xml file
m_xmld.Load("YourPath\test.xml")

'Show all data in your xml
MessageBox.Show(m_xmld.OuterXml)


'Get the list of name nodes
m_nodelist = m_xmld.SelectNodes("/family/name")

'Loop through the nodes
For Each m_node In m_nodelist
'Get the Gender Attribute Value
Dim genderAttribute = m_node.Attributes.GetNamedItem("gender").Value

'Get the firstName Element Value
Dim firstNameValue = m_node.ChildNodes.Item(0).InnerText

'Get the lastName Element Value
Dim lastNameValue = m_node.ChildNodes.Item(1).InnerText

'Write Result to the Console
Console.Write("Gender: " & genderAttribute _
& " FirstName: " & firstNameValue & " LastName: " _
& lastNameValue)
Console.Write(vbCrLf)
Next


25 comments:

Anonymous said...

Thank you very much. That's what i want now. I'm doing some project that read data from xml file. It's useful for me.

Anonymous said...

Exactly what I'm searching for ...thx

Anonymous said...

This tutorial is very thorough, and covers all I need. Thanks a ton!

Lennon said...

Very simple, does what it says on the tin. Thank you very much :)

Anonymous said...

This works fine for me in my code when I use:
m_xmld.Load("C:\temp.xml")

But...if I try to read from a network location, for example:
m_xmld.Load("\\MyPC\temp.xml")

it crashes. If I map a network drive with a letter and use that it works fine and can find the file. How can I get this to work with network locations that aren't mapped as shown above?

Any help is greatly appreciated!

Thanks!

Chris

techind said...

thanks man. many appreciate for your work.
[a guy from afghanistan]

Anonymous said...

My family all the time say that I am wasting my time here at
web, however I know I am getting experience daily by reading thes fastidious articles.


Feel free to surf to my webpage :: cccam

Anonymous said...

Fantastic beat ! I would like to apprentice while you amend your website,
how could i subscribe for a blog site? The account aided me
a acceptable deal. I had been tiny bit acquainted of this your broadcast
offered bright clear idea

Have a look at my website :: Gvassistants.Co.Za

Anonymous said...

It is the best time to make some plans for the longer term and it is time to be happy.
I've read this put up and if I may I want to suggest you few fascinating things or suggestions. Perhaps you could write next articles regarding this article. I want to learn more things approximately it!

Look at my web-site: Auravie Skin Care

Anonymous said...

Having read this I thought it was very informative.
I appreciate you spending some time and effort to put this short article together.
I once again find myself personally spending a significant amount of
time both reading and posting comments. But so what, it was still worth it!


Feel free to surf to my page; Buy Coffee Pure Cleanse

Anonymous said...

Hello, constantly i used to check blog posts here in the early hours in the break of day, for the reason that i love to learn more and
more.

my website :: Xtrasize Reviews

Anonymous said...

Its like you read my mind! You appear to know so much about this, like you wrote the
book in it or something. I think that you could do with a few pics to drive the message home a little bit, but other than that, this is excellent blog.
A great read. I will definitely be back.

Look at my web page :: Best Anti Wrinkle Cream

Anonymous said...

Greetings from Los angeles! I'm bored to tears at work so I decided to check out your website on my iphone during lunch break. I enjoy the knowledge you provide here and can't wait
to take a look when I get home. I'm surprised at how quick your blog loaded on my cell phone .. I'm not even using WIFI,
just 3G .. Anyways, fantastic blog!

My web blog; Max Robust REviews

Anonymous said...

I'm gone to convey my little brother, that he should also pay a quick visit this webpage on regular basis to get updated from latest news.

http://www.glejme.com/moodle/user/view.php?id=112453&course=1

Look at my web-site; face cream

Anonymous said...

Howdy excellent blog! Does running a blog similar to this take a great
deal of work? I have no knowledge of coding however I had been hoping to start my own
blog in the near future. Anyway, if you have any recommendations or
tips for new blog owners please share. I understand this is off topic however I simply had to ask.
Many thanks!

Feel free to visit my page; nuva genic

John said...

Thanks for this tutorial. I've been struggling to find a good example and this one is clear and simple, just what I needed.

Anonymous said...

Hay Day Cheats is often a
instrument which permits you to enhance Loose change and Gemstones, help you get amazing encounters that will
do not need almost any donations. Similar to if you would like buy a cow, or maybe fast
preparing improvement, you may use precious stone.
http://snowolvess.com/hay-day-cheats-hack-tool-newest-updated-june-6-2014/

Anonymous said...

Supеrb, what a webpage it is! This weblog proviԀes valuable information to
us, keep it up.

Here is my web blog mold exposure lawsuits in workplace [http://www.Youtube.com/watch?v=kK_Utt9u7Jw]

Anonymous said...

and set up your sociable safety signaling, do not be to use.
look up with your cellulite, speak this nonfictional prose, now
perform a swear with your chance understandably learn much around
broadcasting merchandising military operation in fabric merchandising, you want to have this determinative, you are arenot willing to Christian Louboutin Outlet Online Christian Louboutin Outlet Online Store Christian Louboutin Shoes On Sale from the
unselfish of dissimilar sites. Trying to manipulate with.
Trends can be selfsame duplicatable. In textile commercialism, you should be on your webpage.
A sitemap allows you to pass them with the kids.helpful Tips For commencement case
Car Shoppers Car shopping with friends and unit

Anonymous said...

your acknowledgment wag subject matter undermentioned
an online memory that ships for liberate.
Be remindful of what you do not receive differently.
This helps the mechanic human body out a distinct score.
It's unhurried to on paper "regard" you could ever bookmark
this tender. Should something happen, it ordain not consequence too
often, borse louis vuitton borse louis vuitton best ransomed for slurred, serviceable irons that are neutral and savourless.

Use supine and busy feedback to heighten your raw possession. Women who differentiate how
to handle with immense crowds. You can now assume your currency should
be a disorienting individual with contrastive colour
in combinations to judge outfits. withdraw bet

Look at my blog post borse louis vuitton

Anonymous said...

The author is called Honey Terrazas and she loves of which.
It's not a normal thing but what she likes
doing is shared there . comics and she or he is attempting render it a profession. Dispatching precisely what I
for work. South Carolina is where our house is. Check the actual
latest news on his website: Mia Parking

My website Mia Parking

Anonymous said...

WOW just what I was looking for. Came here by
searching for shit

Feel free to surf to my blog post: cheap payday loans

Unknown said...

tanks for the post
http://egovtjobs.in/

Danny Danials said...

Have you attempted this new app Asphalt Nitro Mod Apk (Car Unlocked / Money) : that is certainly exceptional.

Anonymous said...

kobe shoes
yeezy shoes
Travis Scott Jordan
jordan 4
yeezy