Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hi there, i have following xml file

Status
Not open for further replies.

baran121

Programmer
Sep 8, 2005
337
TR
hi there, i have following xml file.
i want to get data from this xml to my visual basic 6 program.
i try to use this:

Set oparser = CreateObject("msxml2.domdocument")
bRet = oparser.loadXML(str_xml)

If bRet Then
For i = 0 To celemi6.Length - 1
For j = 0 To celemi6(i).Attributes.Length - 1
MsgBox celemi6(i).Attributes.getNamedItem("PartNumber").Text
Next
Next
end if

but there is a problem, because i cant get sub info from xlm file.
just first <PartInfo>
i wanna get data all <PartInfo> for each <Plan>
i need your help,
thank you...

<Plan>
<VehicleInfo>
<VehicleGroup>BUS</VehicleGroup>
<VehicleCode>BA23K126</VehicleCode>
<Chassis>A235734</Chassis>
<ShipTo>G03</ShipTo>
<DueDate>10/07/2012</DueDate>
<Note>PP:201217|T3 Date:24/05/2012|Fassung Date:24/05/2012|Production Sequence:2|Customer:MAN KAMYON VE OTOBUES TIC. A.S|Country:TR</Note>
</VehicleInfo>
<PartInfo>
<PartNumber>88.76240.0030</PartNumber>
<PartDescription>BAGLANTI CITASI</PartDescription>
<SupplierPartNumber/><SupplierPartDescription/>
<Consignment>Hayır</Consignment>
<Quantity>4</Quantity>
<PartNote>:078ET-Tutamaklar sarı RAL 1018 toz kaplamalı#</PartNote>
</PartInfo>
<PartInfo>
<PartNumber>88.76240.6001</PartNumber>
<PartDescription>BAGLANTI CITASI</PartDescription>
<SupplierPartNumber/><SupplierPartDescription/>
<Consignment>Hayır</Consignment>
<Quantity>4</Quantity>
<PartNote>:078ET-Tutamaklar sarı RAL 1018 toz kaplamalı#</PartNote>
</PartInfo>
</Plan>
 
That's because you are looping through Attributes. You have no attributes here but childNodes!


“Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.” (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 

can you give me the code please. how shoud i use childNodes?
thank you.
 
actually i found following code i still need help :(
when i use the code i see total data i need data seperately.
i need help please.


Set list = xmlDoc.selectNodes("//Plan")
For i = 0 To list.Length - 1
For j = 0 To list.Item(i).childNodes.Length - 1
msgbox list.Item(i).childNodes.Item(j).baseName
msgbox list.Item(i).childNodes.Item(j).nodeTypedValue
next
next

i got following
1. message box -VehicleInfo
2. message box - BUS BA23K126 A235736 D09 10/07/2012 PP:201217|T3 Date:24/05/2012|Fassung Date:24/05/2012|Production Sequence:3|Customer:MAN KAMYON VE OTOBUES TIC. A.S|Country:TR

and next
1. message box -PartInfo
2. message box -81.94297.0249 BORU Hayır 1 078ET-Tutamaklar sarı RAL 1018 toz kaplamalı#

i wanna get all data one by one.
i really need your help, thank you.
 
thank you mikrom. but i think you misunderstood me.
because when i looked at your post (the link) it is different from that i wanted to do.
i ll try to explain more about it.

<VehicleInfo>
<VehicleGroup>BUS</VehicleGroup>
<VehicleCode>BA23K126</VehicleCode>
<Chassis>A235734</Chassis>
<ShipTo>G03</ShipTo>
<DueDate>10/07/2012</DueDate>
<Note>PP:201217|T3 Date:24/05/2012|Fassung Date:24/05/2012|Production Sequence:2|Customer:MAN KAMYON VE OTOBUES TIC. A.S|Country:TR</Note>
</VehicleInfo>

i ll get this data in a master table to my database



<PartInfo>
<PartNumber>88.76240.0030</PartNumber>
<PartDescription>BAGLANTI CITASI</PartDescription>
<SupplierPartNumber/><SupplierPartDescription/>
<Consignment>Hayır</Consignment>
<Quantity>4</Quantity>
<PartNote>:078ET-Tutamaklar sarı RAL 1018 toz kaplamalı#</PartNote>
</PartInfo>
<PartInfo>
<PartNumber>88.76240.6001</PartNumber>
<PartDescription>BAGLANTI CITASI</PartDescription>
<SupplierPartNumber/><SupplierPartDescription/>
<Consignment>Hayır</Consignment>
<Quantity>4</Quantity>
<PartNote>:078ET-Tutamaklar sarı RAL 1018 toz kaplamalı#</PartNote>
</PartInfo>

these two <PartInfo> parts will be used in detail table to my database


so if i do this
Set list = xmlDoc.selectNodes("//Plan")
i got whole data not one by one

so if i do this
Set list = xmlDoc.selectNodes("//Plan/VehicleInfo")
i got data one by one but i cant make a relationship with <PartInfo>

so if i do this
Set list = xmlDoc.selectNodes("//Plan/PartInfo")
i got data one by one but i cant make a relationship with <VehicleInfo>

any hint please...
 
my problem was solved by strongm (MIS)

CODE

Option Explicit

Private Sub CommandButton1_Click()
Dim oParser As DOMDocument
Dim Nodes As Object
Dim MyNode As IXMLDOMNode

Set oParser = New DOMDocument
oParser.LoadXML Text1.Text

For Each MyNode In oParser.ChildNodes
ScanNodes MyNode, 0
Next
End Sub

Private Sub ScanNodes(SourceNode As IXMLDOMNode, ByVal Indent As Long)
Dim MyNode As IXMLDOMNode

If SourceNode.NodeType <> NODE_ELEMENT Then
Debug.Print ": " & SourceNode.NodeValue;

Else
Debug.Print
Debug.Print String$(Indent, vbTab) & SourceNode.BaseName;
Indent = Indent + 1
For Each MyNode In SourceNode.ChildNodes
ScanNodes MyNode, Indent
Next
End If

End Sub


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top