Re: parsing xml
- From: hgeron <hgeron@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 18 Aug 2006 13:18:02 -0700
I tested the code with my landxml file, and it
that listed the first node, then each attribute in the first node then
ended without an error.
I think we need to call the Recurse function from main for each node.
This code should be generic enough to step through any xml file, when
we get it to work.
--
hgeron
"Mark J. McGinty" wrote:
.
"hgeron" <hgeron@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3A93E4AF-572E-4350-B914-D5CC8B2C762F@xxxxxxxxxxxxxxxx
Oh, the error line was ...
For Each Att In Node.Attributes -Error Object required
Yeah, that's what I was talking about a few messages ago, after I looked at
the XML samples...
In the XML they look like this:
<something a1="aaa" a2="bbb">123456</something>
"123456" is a childNode of <something>
So you need to check that attributes isn't nothing:
If Not Node.attributes Is Nothing Then
For Each Att In Node.attributes
If MsgBox(Att.value, vbOKCancel) = vbCancel Then
Exit Function
End If
Next
Else
If MsgBox(Node.data, vbOKCancel) = vbCancel Then Exit Function
End If
-Mark
--
hgeron
"Mark J. McGinty" wrote:
"hgeron" <hgeron@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:D86CEFA0-08A6-4727-8ADC-D06632B3A911@xxxxxxxxxxxxxxxx
It halts before any msgbox at line in function marked "'ERROR- Object
Required...
Set NodeList = xmlDoc.childNodes
Should be Set NodeList = Node.childNodes
---------------------------------------------
Sub mark()
Dim xmlDoc As New MSXML2.DOMDocument50
Dim Node As IXMLDOMNode
Dim NodeList As IXMLDOMNodeList
xmlDoc.Load ("m:\xml\books.xml")
RecurseXML xmlDoc, 0
End Sub
Function RecurseXML(Node As IXMLDOMNode, Level As Long) As Boolean
Dim NodeList As IXMLDOMNodeList
Set NodeList = xmlDoc.childNodes 'ERROR- Object
Required
Dim Att As IXMLDOMAttribute
If NodeList.length = 0 Then
For Each Att In Node.Attributes
If MsgBox(Att.Value, vbOKCancel) = vbCancel Then Exit
Function
Next
Else
For Each Node In NodeList
If MsgBox(Node.XML, vbOKCancel) = vbCancel Then Exit
Function
If RecurseXML(Node, Level + 1) = False Then Exit Function
Next
End If
RecurseXML = True
End Function
--
hgeron
"Mark J. McGinty" wrote:
Sub Foo()
Dim xmlDoc As New MSXML2.DOMDocument50
xmlDoc.Load ("m:\xml\books.xml")
Oops that should be:
RecurseXML xmlDoc, 0
RecurseXML xmlDoc
End Eub
- Follow-Ups:
- Re: parsing xml
- From: Mark J. McGinty
- Re: parsing xml
- References:
- Re: parsing xml
- From: Mark J. McGinty
- Re: parsing xml
- From: hgeron
- Re: parsing xml
- From: Mark J. McGinty
- Re: parsing xml
- From: Mark J. McGinty
- Re: parsing xml
- From: Mark J. McGinty
- Re: parsing xml
- From: hgeron
- Re: parsing xml
- From: Mark J. McGinty
- Re: parsing xml
- Prev by Date: Re: parsing xml
- Next by Date: Re: parsing xml
- Previous by thread: Re: parsing xml
- Next by thread: Re: parsing xml
- Index(es):
Relevant Pages
|
|