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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Xml Attribute Problem 1

Status
Not open for further replies.

kennedymr2

Programmer
May 23, 2001
594
AU
This is the abreviated xml
'*************************

<Pool Type="XX" Available="Y">
<Dividend Id="629" Amount="12.8000">
<DivResult No="1" RNo="2"/>
</Dividend>
<Dividend Id="6291" Amount="13.8000">
<DivResult No="1" RNo="4"/>
</Dividend>
</Pool>

VB6 Code.... working ok

Set oxmlNodeList = xmldoc.selectNodes("//Pool")

For intNode = 0 To oxmlNodeList.length - 1
For intAttr = 0 To oxmlNodeList(intNode).Attributes.length - 1
List2.AddItem oxmlNodeList(intNode).Attributes.getNamedItem("Type").Text
Next
'*** This is where i need to get NO & Rno ie Pick up both DivResults
'Ie I need some child code of some sort ??????
'eg List2.AddItem XX,12.80,1,2
' List2.AddItem XX,13.80,1,4

Next


NOT THIS *********

Set oxmlNodeList = xmldoc.selectNodes("//Pool/Dividend")

For intNode = 0 To oxmlNodeList.length - 1
For intAttr = 0 To oxmlNodeList(intNode).Attributes.length - 1
List2.AddItem oxmlNodeList(intNode).Attributes.getNamedItem("Id").Text
List2.AddItem oxmlNodeList(intNode).Attributes.getNamedItem("Amount").Text
Next
Next


Really appereciate any help

Regards Kennedymr2
 
Code:
[blue]
    Dim xmldoc As New DOMDocument60
    Dim oxmlNodeList As IXMLDOMNodeList
    Dim oxmlSubNodes As IXMLDOMNodeList
    
    Dim node As IXMLDOMNode
    Dim SubNode As IXMLDOMNode
    
    xmldoc.loadXML Text1.Text
    
    Set oxmlNodeList = xmldoc.selectNodes("//Pool/Dividend")
    
    For Each node In oxmlNodeList
        Debug.Print node.Attributes.getNamedItem("Id").Text
        Debug.Print node.Attributes.getNamedItem("Amount").Text
        Set oxmlSubNodes = node.selectNodes("DivResult")
        For Each SubNode In oxmlSubNodes
            Debug.Print SubNode.Attributes.getNamedItem("No").Text
            Debug.Print SubNode.Attributes.getNamedItem("RNo").Text
        Next
        Debug.Print
    Next[/blue]
 
strongm (MIS)...

Thanks once again for the help, much appreciated...i did not think of subnode...

Thanks also for the help you have offered me over the years with various other questions ...

Regards Kennedymr2
 
i am sorry to write here, but i have similar problem.

xml file is below.
i want to get data from this xml to my visual basic 6 program.
i try to use this:

xmldoc.loadXML str_xml

Set oxmlNodeList = xmldoc.selectNodes("//Plan/PartInfo")

For Each node In oxmlNodeList
' Set celemi1 = node.Attributes.getNamedItem("Chassis")
' MsgBox oxmlNodeList.Length - 1
Set Indent = node.ownerDocument.createTextNode(vbNewLine & String(0, vbTab))

Set oxmlSubNodes = node.selectNodes("//Plan/PartInfo")
For Each SubNode In oxmlSubNodes
MsgBox oxmlSubNodes.Length - 1
Set celemi2(SubNode).Text = SubNode.Attributes.getNamedItem("PartNumber").Text
MsgBox celemi2(SubNode).Text
Next
Debug.Print
Next


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>
 
Code:
[blue]    Set oxmlNodeList = xmldoc.SelectNodes("//Plan/PartInfo")
    
    For Each node In oxmlNodeList
        Debug.Print node.nodeName
        For Each SubNode In node.ChildNodes
            Debug.Print vbTab & SubNode.BaseName & ": " & SubNode.Text
        Next
        Debug.Print
    Next[/blue]

 
thank you strongm very much.

but i need little more help.


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


this part is my master table information


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


this part is my datail table information.

i think i need two for next .
thank you again.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top