Re: parsing xml



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




.



Relevant Pages

  • Re: parsing xml
    ... Dim nde As Long ... Dim xmlDoc As New MSXML2.DOMDocument50 ... Function RecurseXML(Node As IXMLDOMNode, ... attnum = attnum + 1 ...
    (microsoft.public.data.ado)
  • Re: Timing Rescordset
    ... I am calling an XML ... Dim nde As Long ... Dim xmlDoc As New MSXML2.DOMDocument50 ... RecurseXML(Node As IXMLDOMNode, ...
    (microsoft.public.data.ado)
  • RE: Run VBA Code from new mail message on standard toolbar
    ... The resolve address issue relates my requirement to be able to call the ... for the same client and I may not know what the Project number is. ... Dim strEmail As String ... Dim objRecipient As Recipient ...
    (microsoft.public.outlook.program_vba)
  • RE: Run VBA Code from new mail message on standard toolbar
    ... The resolve address issue relates my requirement to be able to call the ... for the same client and I may not know what the Project number is. ... Dim strEmail As String ... Dim objRecipient As Recipient ...
    (microsoft.public.outlook.program_vba)
  • Re: VB versus VB.NET timings!!
    ... Dim DataArrayAs Object ... Dim mth, cl As Short ... 'Array now has all the data from the old sheet - close the ... 'UPGRADE_WARNING: Couldn't resolve default ...
    (microsoft.public.dotnet.languages.vb)