Results 1 to 16 of 16

Thread: [RESOLVED] VB6 parssing XML content. Any help please...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    75

    Resolved [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
    Thank you

  2. #2

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    75

    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
    Thank you

  4. #4
    Hyperactive Member
    Join Date
    Dec 2005
    Location
    Toronto, Canada
    Posts
    357

    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.

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    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.

  6. #6

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    75

    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

  8. #8
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    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.

  9. #9
    Hyperactive Member BrendanDavis's Avatar
    Join Date
    Oct 2006
    Location
    Florida
    Posts
    492

    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

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    75

    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
    Thank you

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    75

    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:
    1. 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

  12. #12
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] VB6 parssing XML content. Any help please...

    VB Code:
    1. Dim oxmlNodeList As IXMLDOMNodeList
    2.  Dim lngIndex As Long
    3.  
    4.  Set oxmlNodeList = XMLdoc.documentElement.selectNodes("//title")
    5.  
    6.  For lngIndex = 0 To oxmlNodeList.length - 1
    7.   ' do something
    8.  Next

  13. #13
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: [RESOLVED] VB6 parssing XML content. Any help please...

    Here's additional reading regarding xpath

    http://www.w3schools.com/xpath/default.asp

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    75

    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:
    1. Set objNode = objDoc.selectSingleNode("out/num")

    Thank you so much so far. You guys are great!

    Quote Originally Posted by MartinLiss
    VB Code:
    1. Dim oxmlNodeList As IXMLDOMNodeList
    2.  Dim lngIndex As Long
    3.  
    4.  Set oxmlNodeList = XMLdoc.documentElement.selectNodes("//title")
    5.  
    6.  For lngIndex = 0 To oxmlNodeList.length - 1
    7.   ' do something
    8.  Next
    Thank you

  15. #15
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] VB6 parssing XML content. Any help please...

    VB Code:
    1. Set oxmlNodeList = XMLdoc.documentElement.selectNodes("//title")
    2.     Dim oxmlElement As IXMLDOMElement
    3.    
    4.     For lngIndex = 0 To oxmlNodeList.length - 1
    5.         Set oxmlElement = oxmlNodeList(lngIndex).parentNode
    6.         MsgBox oxmlElement.getAttribute("num")
    7.     Next
    Since you've marked this as resolved, if you need more help it would be better to start a new thread.

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    75

    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
    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width