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

Xml Get Attributes 1

Status
Not open for further replies.

kennedymr2

Programmer
May 23, 2001
594
AU
I am new to xml....

I have the following code which seems to get me the nodes all ok.

But i would like to get the Attribute Names and values as well..eg the line looks like
<ESchedule>
<EID="1054337_01" EC="XXX" />

The code i am using is....i guess i need the attributes where i have ????????????????????

Public Function RecurseChildNodes(xmlDoc As MSXML2.DOMDocument30, childNode As IXMLDOMNodeList)

Dim CurrChildNode As IXMLDOMNodeList
Dim CurrChildNode2 As IXMLDOMNodeList
Dim intNodeCounter As Integer

Set CurrChildNode = childNode

For intNodeCounter = 0 To CurrChildNode.length - 1

If CurrChildNode.length > 0 Then
Set childNode = CurrChildNode.Item(intNodeCounter).childNodes
If childNode.length > 0 Then
RecurseChildNodes xmlDoc, childNode
Me.Txt.text = Me.TxtXmlOut.Text & CurrChildNode.Item(intNodeCounter).nodeName & "= " & CurrChildNode.Item(intNodeCounter).nodeTypedValue & vbCrLf
'?????????????????????????????????
End If
End If

Next intNodeCounter

End Function

Alternatively...!!! Just some simple code that does a list of all nodes and the attributes.......

If someone has the time i would really apprciate the help

Regards Kennedymr2
 
>'?????????????????????????????????
[tt]
'dim attr as IXMLDOMAttribute 'somewhere above
for each attr in CurrChildNode.Item(intNodeCounter).Attributes
'desired properties : attr.NodeName, attr.NodeValue
debug.print attr.nodename & vbcrlf & attr.nodevalue
next
[/tt]
 
I now see a couple of your related posts, you always put this without conscience of it being wrong (possible a typo):
>[tt] <EID="1054337_01" EC="XXX" />[/tt]
This cannot be right. Read the original document carefully.
 
tsuji

Appreciate your interest in helping

I have put the code into my program,but it does not pick up the attributes

I have created a NEW simple small xml file to visually see what i am trying to do...

<Data>
<EventSchedule>
<Event ID="1054337" EventStatus="GOOD" />
<Event ID="1054160" EventStatus="BAD" />
</EventSchedule>
</Data>

I am trying to get the attribute name eg ID and the value 1054337

MY current program picks up EventScedule ok. but not the attributes

Appreciate any ideas as to why it is not working

Regards Kennedymr2

 
>MY current program picks up EventScedule ok. but not the attributes
There is zero attribute for EventSchedule, if that is not a matter of vocabulary. The Event has two attributes-that's how the language is applied. You have to pick up Event begin you have a return of attribute's nodename and nodevalue. I don't think what I posted has any major problem: in fact there is none as for the xml of the kind.
 
tsuji

Thanks for your advice, its much appreciated.

I now have it working, all ok.

I will do some study of xml.!!!@@@

Regards Kennedymr2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top