Extracting data from xml using vb 6

I have a 2 part problem.  I have an application that needs to get data from an xml document that is loaded.  The document is in the format shown below.  

Problem 1:  I need to get all of the info from the document between <Islands> and </Islands>.  I'm trying the following but am receiving an error on compile: Invalid use of property

    Dim xmlPSIDGroup As IXMLDOMNodeList
    xmlPSIDGroup = xmlRequest.selectNodes("Form/Islands/PSIDGroup")

Problem 2: Once I have the informaiton, I need to add it to another xml document so it looks like document 2 shown below.

Any help would be greatly appreciated.  I am on a tight deadline and am spinning my wheels right now.
Document 1
==========
<Form><Islands><PSIDGroup><prsvalue>Test</prsvalue><id>0</id><insertflag>T</insertflag></PSIDGroup><Assigned><row><id>1</id><insertflag>F</insertflag></row></Assigned><Unassigned><row><id>2</id><insertflag>T</insertflag></row><row><id>3</id><insertflag>T</insertflag></row></Unassigned></Islands></Form>

Document 2
===========
<ValidationErrors><row><Error>Error message</Error></row><row><Error>Next Error</Error></row></ValidationErrors><Recordsets>><PSIDGroup><prsvalue>Test</prsvalue><id>0</id><insertflag>T</insertflag></PSIDGroup><Assigned><row><id>1</id><insertflag>F</insertflag></row></Assigned><Unassigned><row><id>2</id><insertflag>T</insertflag></row><row><id>3</id><insertflag>T</insertflag></row></Unassigned></Recordsets>

Open in new window

dyaroshAsked:
Who is Participating?
 
HooKooDooKuCommented:
You don't indicate what the object "xmlRequest" is.
The only xml work I've done used a Node object to do a selectNodes.
For example, to get everything within the PSIDGroup, I would do the following...

Dim Doc as MSXML2.DOMDocument40
Dim FormNode as MSXML2.IXMLDOMElement
Dim IslandsNode as MSXML2.IXMLDOMElement
Dim PSIDNodes as MSXML2.IXMKDOMNodeList
Doc.Load("Document 1")
Set FormNode = Doc.DocumentElement  'Root Node
Set IslandNode = FormNode.selectSingleNode("./Islands")
Set PSIDNodes as IslandNode.selectNodes(./PSIDGroup)

This can likely be short-cutted with something like

Doc.Load("Document 1")
Set PSIDNodes = Doc.DocumentElement.selectNodes(./Form/Islands/PSIDGroup)

But that would get all PSIDGroup nodes that might be embedded in multiple Islands ndoes.

From there, you can continue to get individual nodes within an node object, or list of nodes within a node object.  Then you need a Doc2 object for Document 2, get a reference to the node where you want to insert other node objects into, and use the command "insertBefore" to copy a node to the new document.
0
 
dyaroshAuthor Commented:
Request is defined as follows:

Dim xmlRequest As FreeThreadedDOMDocument40
0
 
dyaroshAuthor Commented:
I changed the xmlPSIDGroup definition to the following  :Dim xmlPSIDGroup As DOMDocument

Error:
object variable or with block variable not set
0
 
dyaroshAuthor Commented:
I found what caused my error.  I forgot to use SET.  Thanks for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.