Re: parsing xml
- From: hgeron <hgeron@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 20 Aug 2006 08:08:01 -0700
I'll try that, thanks you've been a great help
--
hgeron
"Mark J. McGinty" wrote:
.
"hgeron" <hgeron@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E3233D51-C3FF-4190-AE39-DB1D61E71AC9@xxxxxxxxxxxxxxxx
Well, that certaintly listed everything.
I have never got Debug.print to work for me... maybe it does not work
in an Access vb module.
I thought VBA supported it... docs say it does. <shrug> It only works when
running in debugging mode; it dumps output to the immediate window.
I wrote the output to a file. The node "catalog" thru the end of the XML
is
output
several times. I cut nodes off at 20 chars max, and the output was 16kb.
The whole books.xml was only 5kb. The extra size is repeating nodes. I
didn't see any attributes repeated. I know you have spent a lot of time
on
this, but do you see a way of avoiding repeating nodes? I thought about
capturing the node output and
comparing it to the last, but that wouldn't work because when nodes are
within other nodes, the repeating node is not the last node.
It's repeating the same output because you are dumping Node inside a loop
that doesn't change it. ChildNode is the one used by For Each.
The other duplication you are seeing is because you are dumping the xml
property. Try .name and .value for attributes, and .nodeName, .nodeValue
for nodes. That still effectively dumps 2 copies of each NODE_TEXT node,
the parent nodes of which are apparently named #text... making the NODE_TEXT
output redundant.
-Mark
Here's my code now.
Option Compare Database
Dim Opened As Boolean
Sub mark()
Dim xmlDoc As New MSXML2.DOMDocument50
Dim Node As IXMLDOMNode
Dim NodeList As IXMLDOMNodeList
Open "c:\temp\output.txt" For Output As #1: Reset
xmlDoc.Load ("m:\xml\books.xml")
'xmlDoc.Load ("m:\xml\bittner2.xml")
RecurseXML xmlDoc.documentElement, 0
Reset
End Sub
Function RecurseXML(Node As IXMLDOMNode, Level As Long) As Boolean
Dim NodeList As IXMLDOMNodeList
Dim ChildNode As IXMLDOMNode
If Not Opened Then Open "c:\temp\output.txt" For Append As #1: Opened =
True
'MsgBox ("Begin Recurse Level: " & Level)
Print #1, "Begin Recurse Level: "; Level
Set NodeList = Node.childNodes
Dim Att As IXMLDOMAttribute
If Not Node.Attributes Is Nothing Then
attnum = 0
For Each Att In Node.Attributes
attnum = attnum + 1
'MsgBox ("ATTR:" & vbCr & Att.Value)
Print #1, "ATTR:"; attnum, Att.XML, Att.Value
Next
End If
If Node.nodeType = NODE_TEXT Then
'MsgBox "NODE_TEXT:" & vbCr & Node.XML
Print #1, "NODE_TEXT:"; nde, Node.XML
Else
If Not NodeList Is Nothing Then
For Each ChildNode In NodeList
nde = nde + 1
'MsgBox ("NODE: " & vbCr & Node.XML)
Print #1, "NODE:(left 20 of"; Len(Node.XML); " chars):";
Left(Node.XML, 20)
If RecurseXML(ChildNode, Level + 1) = False Then Close 1:
Opened = False: Exit Function
Next
End If
End If
RecurseXML = True
End Function
- 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
- 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
|
|