Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[tut][VB.net]Create an XML parser!(use these methods for lots of stuff!)

IMAGES DOWN! This is an old tutorial of mine, I need to find my original screenshots or make some new ones.

Before I begin, this is a tutorial on how to create an XML parser for you program.
XML can be used in many ways, in this example I will show you how to create an XML parser that will read from an XML file for a "news" form.

Before we begin, make sure you have these imported:
Code
Imports System.IO
Imports System.Xml

Now put together your interface, make sure you have at least 3 read only text boxes and 1 button, make one textbox "authorfield", make another one "datefield", and the last one "newsfield".
Place them where you want, you can guess where they go.. :P
("newsfield" needs to be multiline)

I set mine together like this:
My interface (Click to View)

The button can be named anything, but in my case I named it "getnews".

Now double click the button, and place the imports I showed you above at the top, it should look like this:
Screenshot (Click to View)

Now add the following code in between the button's onclicked code:
Code
Dim m_xmlr As XmlTextReader
m_xmlr = New XmlTextReader(Application.StartupPath & "\newsdata.xml")
m_xmlr.WhitespaceHandling = WhitespaceHandling.None

In this example I am getting the XML file "newsdata.xml" from the application startup directory, you can get the XML file from anywhere.
Before I get started with the major coding, you need to make the XML file to parse.
Here it is:
Code
<XML>
    <author></author>
    <date></date>
    <content></content>
</XML>
Save that as a .xml file.

So basically, our parser will read the data in between the "author" field and show it, read the data in between the "date" field and show it, and then read the data in between the "content" field.

Now add:
Code
m_xmlr.Read()
m_xmlr.Read()
Dim authorvalue = m_xmlr.ReadElementString("author")
Dim datevalue = m_xmlr.ReadElementString("date")
Dim contentvalue = m_xmlr.ReadElementString("content")
authorfield.Text = authorvalue
datefield.Text = datevalue
newsfield.Text = contentvalue
m_xmlr.Close()

From there on, make sure there are no errors.
It should look like:
Screenshot (Click to View)

Now tell you application to "build", save you XML file, place the XML file with the application.

Now run you application and press the button you made with it!
It should read from the XML file and bring back the details you gave it.
Make sure the XML file isn't blank!

A screenshot of the result:
Screeshot of running application (Click to View)

I used the XML code:
Code
<XML>
   <author>tannerzion</author>
   <date>3/5/2010</date>
   <content>Hello there peepz!</content>
</XML>

To get that result.

Have fun messing around with this!

The source is here:
Url down, please wait for me to find it on my end.
[Image: etRrWjZ.png]
Absolutely GREAT tut!
I've been looking for something like this!
Thanks a bunch!

I'd +rep you if I had leet!
Useful tutorial, thanks...
Your welcome!

This is the first tutorial of its kind on hack forums.
[Image: etRrWjZ.png]
I'm sure you guys could put this to so many other uses.
[Image: etRrWjZ.png]
Well, if anyone does use these methods please link me to your thread, I want to see how creative you got with them.
[Image: etRrWjZ.png]
Useful tutorial. I know XML parsers can e used for a variety of programs. Just wanted to ask, can I make an anti-virus that reads the XML database for virus signatures? I suppose I can.
(Mar 5, 2010 11:31 PM)--([-S7N-])-- Wrote:  Useful tutorial. I know XML parsers can e used for a variety of programs. Just wanted to ask, can I make an anti-virus that reads the XML database for virus signatures? I suppose I can.

Of course :P.

You can make login systems to, xD.

Advanced HWID verification.

So many possibilities!

Anyway, I'm making a news system, with a builder :D
[Image: etRrWjZ.png]
Peaple asking for filezilla stealer and pidgin stealer should be redirected here.
Thank's for this, is there any way i can set it to get the xml file off a website? would it just be as easy as typing the url where the file directory is?
xhtmlphp, this all is so simple..
To make it read from an XML file off a website, just direct to the XML file itself(say, https://hackforums.net/yourxmlfile.xml).
[Image: etRrWjZ.png]
If i wont to delete an entry??
(Mar 11, 2010 04:54 AM)GoldStar Wrote:  Peaple asking for filezilla stealer and pidgin stealer should be redirected here.

Very true. Good tut Tanner. 🤝
Thanks iRtehLeet!

Bump for my thread.
[Image: etRrWjZ.png]
Thanks for this... :)

Bump for you!


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by HackersFeb 28, 2024 09:00 AM 4 215 Feb 28, 2024 09:00 AM
Last Post: Hackers
[.NET] by Shadow ReignJul 18, 2018 04:14 AM 3 129 Jul 18, 2018 04:14 AM
Last Post: sh@rp
[.NET] by BarretJan 30, 2018 08:25 AM 21 879 Jan 30, 2018 08:25 AM
Last Post: Ninja