Re: parsing xml
- From: hgeron <hgeron@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 23 Aug 2006 16:05:02 -0700
oops, I meant "I can't resolve."
--
hgeron
"hgeron" wrote:
Mark,.
I have a small problem I can resolve.
Consider the XML node.
<P id="1" desc="268" name="BL">4920.05 3396.07 91.56</P>
"Our code" resolves this as two nodes. The first node has the node name as
"P"
and finds the three attributes as 1, 268 and BL.... all this is correct, but
then
it proceed to the next node and finds it has "node text", but it has no node
name, but it has the node.text properly as 4920.05 3396.07 91.56.
The problem is that it's not two nodes (at two different levels) it is one
node with attributes and text. I have tried many different ways, but I
can't get this coded as one node. By the way, it works terrific except for
this one thing.
All of these node names, attributes, and node.text values are going into a
Access Table. Can you see logic to make this one node instead of two?
Here's my code...
Option Compare Database
Dim nde As Long
Sub mark()
Dim xmlDoc As New MSXML2.DOMDocument50
Dim Node As IXMLDOMNode
Dim NodeList As IXMLDOMNodeList
xmlDoc.Load ("e:\xml\bittner2.xml")
nde = 0
'Delete all records from XML table
DoCmd.OpenQuery "Query1", acViewNormal, acEdit
RecurseXML xmlDoc.documentElement, 0
Close
End Sub
Function RecurseXML(Node As IXMLDOMNode, Level As Long) As Boolean
Dim NodeList As IXMLDOMNodeList
Dim ChildNode As IXMLDOMNode
Dim Att As IXMLDOMAttribute
Set NodeList = Node.childNodes
Set rst = CurrentDb.OpenRecordset("XML")
nde = nde + 1
rst.AddNew
rst("nodenumber") = nde
rst("node") = Node.baseName
rst("Level") = Level
If Not Node.Attributes Is Nothing Then
attnum = 0
For Each Att In Node.Attributes
attnum = attnum + 1
Select Case attnum
Case 1: rst("att1") = Left(Att.Value, 100)
Case 2: rst("att2") = Left(Att.Value, 100)
Case 3: rst("att3") = Left(Att.Value, 100)
Case 4: rst("att4") = Left(Att.Value, 100)
Case 5: rst("att5") = Left(Att.Value, 100)
Case 6: rst("att6") = Left(Att.Value, 100)
Case 7: rst("att7") = Left(Att.Value, 100)
Case 8: rst("att8") = Left(Att.Value, 100)
Case 9: rst("att9") = Left(Att.Value, 100)
Case Else: rst("attElse") = Left(Att.Value, 100)
End Select
Next
rst.Update
End If
If Node.nodeType = NODE_TEXT Then
rst("nodetext") = Node.XML
rst.Update
Else
If Not NodeList Is Nothing Then
For Each ChildNode In NodeList
If RecurseXML(ChildNode, Level + 1) = False Then 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
- From: hgeron
- Re: parsing xml
- From: Mark J. McGinty
- Re: parsing xml
- From: hgeron
- Re: parsing xml
- Prev by Date: Re: VB6 Access97
- Next by Date: Re: parsing xml
- Previous by thread: Re: parsing xml
- Next by thread: Re: parsing xml
- Index(es):
Relevant Pages
|
|