|
-
Jan 30th, 2007, 08:44 PM
#1
Thread Starter
Lively Member
-
Jan 30th, 2007, 09:26 PM
#2
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.
-
Jan 30th, 2007, 09:39 PM
#3
Thread Starter
Lively Member
-
Jan 30th, 2007, 10:00 PM
#4
Hyperactive Member
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
Hey... If you found this post helpful please rate it.

-
Jan 30th, 2007, 10:36 PM
#5
Re: VB6 parssing XML content. Any help please...
 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.
-
Jan 30th, 2007, 10:37 PM
#6
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.
-
Jan 30th, 2007, 11:57 PM
#7
Thread Starter
Lively Member
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.
Thank you 
-
Jan 30th, 2007, 11:59 PM
#8
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.
-
Jan 31st, 2007, 01:34 AM
#9
Hyperactive Member
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
God put me on this earth to do many great things, and I'm so far behind that I'm going to live forever.
I'm programming for Windows using a Apple Mac Mini, 1.5Ghz with 512MB DDR RAM. I feel like I'm committing a crime :P
-
Jan 31st, 2007, 01:57 AM
#10
Thread Starter
Lively Member
Re: VB6 parssing XML content. Any help please...
 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
Thank you 
-
Jan 31st, 2007, 11:52 PM
#11
Thread Starter
Lively Member
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
Thank you 
-
Feb 1st, 2007, 10:12 AM
#12
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
-
Feb 1st, 2007, 10:55 AM
#13
Re: [RESOLVED] VB6 parssing XML content. Any help please...
Here's additional reading regarding xpath
http://www.w3schools.com/xpath/default.asp
-
Feb 2nd, 2007, 01:37 AM
#14
Thread Starter
Lively Member
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! 
 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
Thank you 
-
Feb 2nd, 2007, 10:20 AM
#15
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.
-
Feb 2nd, 2007, 12:39 PM
#16
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|