[RESOLVED] VB6 parssing XML content. Any help please...
Hi,
What would be the "components" / references required to first download a XML file from my site, then use VB to parse the content and put it in a "label" may be...
Secondly, do you know of any tutorial/ code which I can use to parse the xml content? (This is more important.)
I know that I can simply use a browser and just navigate to my php site, but what's the fun in it?
Thank you :)
Bye :)
Re: VB6 parssing XML content. Any help please...
You will find that you'll need to use MSXML2, 3 or 4 (the DOM) to parse the XML file. There are many examples in these forums if you do a search.
Re: VB6 parssing XML content. Any help please...
Yes, I came across a tutorial which mentioned MSXML2 and the DOM parsing example as well...
I do have a little confusion though. :)
The tutorial mentioned that I have to download that pack, install it and then from "references" add it in my project.
When I make the EXE file and give it to someone else, will they also have to first "install" the MSXML pack from microsoft website, or they can just double click and start using?
Secondly, I took a look in my reference list and found 3 versions of "microsoft XML v..." listed there already. These are:
"microsoft XML v2.6"
"microsoft XML v3"
and "microsoft XML version 2"
Is this the same thing, or something else?
I am just starting to learn VB... Sorry for such newbe questions. Please bare with me. :)
Thank you :)
Re: VB6 parssing XML content. Any help please...
They are different versions of the same component... just use 3.0... i believe it is not that new... Just a note... Usually for references, try using the most common ones because... for example... a Microsoft Excel 11.0 reference will not work unless you have Microsoft Excel 2003 installed... I hope you understand what I am saying
Khanjan
Re: VB6 parssing XML content. Any help please...
Quote:
Originally Posted by khanjan_a2k
They are different versions of the same component... just use 3.0... i believe it is not that new... Just a note... Usually for references, try using the most common ones because... for example... a Microsoft Excel 11.0 reference will not work unless you have Microsoft Excel 2003 installed... I hope you understand what I am saying
Khanjan
That caution only applies when you are interfacing with an external application. When you use MSXML everything you need is internal to your program.
Re: VB6 parssing XML content. Any help please...
Oh, and you most likely want to use MSXML4, but whatever you already have on your PC will work for most applications.
Re: VB6 parssing XML content. Any help please...
Ok, so I don't have to worry about compatibility... (Oh but got to make this first___)
You guys are really nice people!
Thank you :)
I'm sure I will come back with more newbe questions.
Bye till then.
See you soon. :)
Re: VB6 parssing XML content. Any help please...
Now that we've helped you with this question, you can help us by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button which will let everyone know that you have your answer.
Re: VB6 parssing XML content. Any help please...
Why not just write a function to do so? Download the file from the web(which is easy enough, search the forums and you'll find plenty of examples I'm sure), and then write a function to get the sections and such.
It's not terribly difficult, actually. It's one of the more easier document formats to parse, because things are (or SHOULD be, when writing XML) organized fairly accurately and neatly. I wrote a small function that, for example, parses an XML file and adds the key's and child key's to a listview. It's pretty much the same as XML Notepad 2007, actually :D
Re: VB6 parssing XML content. Any help please...
Quote:
Originally Posted by MartinLiss
Now that we've helped you with this question, you can help us by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button which will let everyone know that you have your answer.
Nice, I saw "resolved" in titles of some other threads and thought that moderaters were doing it. Didn't knew I can do it myself! Nice addition :)
BrendanDavis, Can you please help in writing the function? I tried, using the tutorial I found, but keeps giving me debugging errors... This is how my xml file looks like:
<?xml version="1.0"?>
<main id="25"> <!--Id is important-->
<out num="64"> <!--num is important-->
<title>title here</title>
<description>Description here</description>
<link>full url here</link>
</out>
<out num="104">
<title>title here</title>
<description>Description here</description>
<link>full url here</link>
</out>
</main>
Thank you :)
Re: [RESOLVED] VB6 parssing XML content. Any help please...
Here's a thread I found which has a working example: :)
http://www.vbforums.com/showthread.p...ight=parse+xml
It works very well. But I have a doubt though...
When I use:
VB Code:
Set objNode = objDoc.selectSingleNode("main/out/title")
it displays the first "title". How will I get the second "title"?
Also is there a way to get the attribute value of "num" placed within "out" tag?
Thank you :)
Re: [RESOLVED] VB6 parssing XML content. Any help please...
VB Code:
Dim oxmlNodeList As IXMLDOMNodeList
Dim lngIndex As Long
Set oxmlNodeList = XMLdoc.documentElement.selectNodes("//title")
For lngIndex = 0 To oxmlNodeList.length - 1
' do something
Next
Re: [RESOLVED] VB6 parssing XML content. Any help please...
Here's additional reading regarding xpath
http://www.w3schools.com/xpath/default.asp
Re: [RESOLVED] VB6 parssing XML content. Any help please...
Works perfect!
Thanks :)
Also can I pull the "attribute" in the node? For example the "out" tag above has a "num" inside the same tag:
<out num="250">
<title>some text</title>
</out>
I tried this, but gives me a debug error:
VB Code:
Set objNode = objDoc.selectSingleNode("out/num")
Thank you so much so far. You guys are great! :)
Quote:
Originally Posted by MartinLiss
VB Code:
Dim oxmlNodeList As IXMLDOMNodeList
Dim lngIndex As Long
Set oxmlNodeList = XMLdoc.documentElement.selectNodes("//title")
For lngIndex = 0 To oxmlNodeList.length - 1
' do something
Next
Re: [RESOLVED] VB6 parssing XML content. Any help please...
VB Code:
Set oxmlNodeList = XMLdoc.documentElement.selectNodes("//title")
Dim oxmlElement As IXMLDOMElement
For lngIndex = 0 To oxmlNodeList.length - 1
Set oxmlElement = oxmlNodeList(lngIndex).parentNode
MsgBox oxmlElement.getAttribute("num")
Next
Since you've marked this as resolved, if you need more help it would be better to start a new thread.
Re: [RESOLVED] VB6 parssing XML content. Any help please...
You are so good! :) All my questions are answered.
Thank you so much for these codes. I couldn't have moved a step ahead without these.
Thank you :)
Bye :)