none
How to get xml element value using DOM from HTTP Response which base xml?

    Question

  • How to get xml element value using DOM from HTTP Response which base xml?

    I want to get code value.

    Successed in get xml element value which is local xml file,but failed in http response.

    thanks

    Xml file:

    <?xml version="1.0" encoding="UTF-8"?>

     

    <result>

      <CallIdentifier>182282878</CallIdentifier>

      <code>1100</code>

    </result>

     

    Code:

    Set ObjDomDocument = CreateObject("MSXML2.DOMDocument")

    ObjDomDocument.async = False

    ObjDomDocument.LoadXML XHR.responseText

     

    Dim XmlNodeList As MSXML2.IXMLDOMNodeList

    Dim XmlNode As MSXML2.IXMLDOMNode

    Dim MyXmlNode As MSXML2.IXMLDOMNode

           

    Set XmlNodeList = ObjDomDocument.getElementsByTagName("*")

     

    For Each XmlNode In XmlNodeList

        For Each MyXmlNode In XmlNode.ChildNodes

                 Debug.Print MyXmlNode.NodeValue

        Next MyXmlNode

    Next XmlNode


    Set ObjDomDocument = Nothing

    Monday, July 22, 2013 4:28 AM

All replies

  • 2cryptic

    Typically you would get the innerHtml value of the element you are looking for. You can iterate over all elements like you are doing, or just use getElementById.

    Note that javascript and the DOM are case-sensitive.


    -Tom. Microsoft Access MVP

    Monday, July 22, 2013 4:47 AM
  • thanks Tom

    not case-sensitive,change Set XmlNodeList = ObjDomDocument.getElementsByTagName("*") to

    Set XmlNodeList = ObjDomDocument.getElementsByTagName("code"),still failed to get value.

    Monday, July 22, 2013 5:36 AM