Reading XML from VB.Net and storing in variable

Hello I am trying to retrieve a 'tag'(Is it called that?) from an XML webpage. Once I make a post request from my vb.net app it sends a command to my online webserver and redirects me to a page that has entries that change each time. The page that im redirected to that changes each time looks something like this:

<mainpage> <id>hello</id> <random>176</random> </mainpage>

What vb.net code would I use to retrieve the id (In this case 'hello') and store it in a variable. I appreciate any help :)

Answers


in vb.net (not tested)

dim doc as XDocument = XDocument.Parse(stringContainingXML)
dim valueOfIdElement as string = (doc...<id>).first.value

You should look at the documentation for the System.Xml.Linq namespace.


Need Your Help

System.Drawing.Printing Drawing String vertically fromRight to Left in rectangle center alignment

c# winforms printing system.drawing

I want to draw a string in a specified rectangle(vertical direction), Below code gives me wat I am after but the text flow is from Left to Right, What I am trying to is Right to Left. Like Line 1 o...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.