Re: parsing xml




"hgeron" <hgeron@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A1657E7E-72F2-47B9-AFEC-521E4ADC60F3@xxxxxxxxxxxxxxxx
MSXML5 is confusing.

There should be a simple way, once the DOM is accessed
in an Access module (VB and ADO) to

locate the root node and walk thru each and every
node, element, and attribute... but I have not been able
to figure out the MSXML keywords.

1. Set the DOM
2. find how many nodes

No need with For Each...

Dim Node As MSXML.IXMLDOMNode
Dim NodeList As MSXML.IXMLDOMNodeList
Set NodeList = Dom.childNodes
For Each Node In NodeList
[...]
Next

3. for each node ; msgbox the node

You could be clicking Ok for a long time! :-)

4. find how many elements
5. for each element ; msgbox the element

I'm not sure how the concept of elements (as opposed to nodes) applies. A
node has a ChildNodes collection and an Attributes collection. You would
have to recurse each node with ChildNodes.length > 0.

6. find how many attributes
7. for each attribute ; msgbox the attribute

Dim Attribute As MSXML.IXMLDOMAttribute
For Each Attribute In Node.Attributes
[...]
Next

One sub routine should read any XML, right?
Of course depending on the responses, you could program
the correct followup, but why wouldn't this work...

Impossible to even speculate without seeing your code. Does it throw any
errors? Have you stepped through it in the debugger and examined the
object[s] state[s] at each step.


I can't make it work. Does anyone out there work with this?

I do, surely thousands of others do as well. Note that all object name
examples above assume MSXML 2.0, the library prefix will have to be
adjusted, perhaps some object/interface names as well (but I think all of
them I mentioned are valid in later versions.)


-Mark


Harrell Geron






--
hgeron


.



Relevant Pages

  • Re: parsing xml
    ... Dim xmlDoc As New MSXML2.DOMDocument50 ... to figure out the MSXML keywords. ... node has a ChildNodes collection and an Attributes collection. ... for each attribute; msgbox the attribute ...
    (microsoft.public.data.ado)
  • "No Properties" error... cant navigate dom elements. Please help...
    ... for some reason i am not able to navigate the dom. ... Dim editcriteriacmd As System.Data.SqlClient.SqlCommand = New ... the response is parsed in the dataResponseHandler function. ... var search = ...
    (comp.text.xml)
  • Re: Export Query To XML
    ... Open SQL in ADO Recordset ... Save recordset to DOM ... Dim szConnect As String ... Dim xmlDoc As DOMDocument ...
    (comp.databases.ms-access)
  • Re: Export Query To XML
    ... Save recordset to DOM ... > Dim szConnect As String ... > Dim oCN As ADODB.Connection ... > ' Dim xmlDoc As MSXML2.DOMDocument40 ...
    (comp.databases.ms-access)
  • Re: Switching ADO RecordSet Connections
    ... > Then open a recordset on the XML object, connect it and call UpdateBatch. ... > Dim dom As MSXML.DOMDocument ... > Dim Node As MSXML.IXMLDOMNode ... > Set ChildNodes = DataNode.ChildNodes ...
    (microsoft.public.vb.database.ado)