ServerXMLHTTP and nodeValue versus nodeTypedValue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adam David Moss

    ServerXMLHTTP and nodeValue versus nodeTypedValue

    All,

    Long time since I've done some proper coding in ASP and I've hit a wee snag
    that has got me baffled. Well two actually but the other is to do with
    running pages under Sun ASP so we'll not go there! Anyway, I digress...

    I've cobbled together some code as shown below (removed error checking etc
    for simplicity). This uses ServerXMLHTTP to grab an XML file off a remote
    server. When querying the result, however, the nodeValue property is null
    whereas the nodeTypedValue property isn't.

    Can anyone please advise as this I would expect nodeValue to be populated.

    Cheers,


    Adam M.

    ===== BEGIN_TESTPAGE. ASP ====
    <%
    Dim objXMLHTTP

    Set objXMLHTTP = Server.CreateOb ject("MSXML2.Se rverXMLHTTP")

    With objXMLHTTP
    .open "GET", "http://www.myserver.eu/test.asp", False
    .send

    Response.Write "Status: " & .status & "<br />"
    Response.Write "Parse:" & .responseXML.pa rseError.errorC ode & "<br />"

    Response.Write
    ..responseXML.d ocumentElement. childNodes(0).c hildNodes(0).no deTypedValue
    Response.Write
    ..responseXML.d ocumentElement. childNodes(0).c hildNodes(0).no deValue
    End With

    Set objXMLHTTP = Nothing
    %>
    ===== END_TESTPAGE.AS P =====

    ===== BEGIN_TEST.ASP =====
    <% Option Explicit

    With Response
    .Buffer = True

    .AddHeader "Pragma", "no-cache"

    .CacheControl = "no-cache"

    .Expires = -1

    .ContentType = "text/xml"

    .Charset = "UTF-8"
    End With %><?xml version="1.0" encoding="UTF-8" standalone="yes " ?>

    <tLRecords>
    <tLRecord>
    <tL>A</tL>
    <tLD>B</tLD>
    <tLED>2008-06-24</tLED>
    <rL>C</rL>
    <rLD>D</rLD>
    </tLRecord>
    </tLRecords>
    ===== END_TEST.ASP =====

  • Martin Honnen

    #2
    Re: ServerXMLHTTP and nodeValue versus nodeTypedValue

    Adam David Moss wrote:
    Long time since I've done some proper coding in ASP and I've hit a wee
    snag that has got me baffled. Well two actually but the other is to do
    with running pages under Sun ASP so we'll not go there! Anyway, I
    digress...
    >
    I've cobbled together some code as shown below (removed error checking
    etc for simplicity). This uses ServerXMLHTTP to grab an XML file off a
    remote server. When querying the result, however, the nodeValue
    property is null whereas the nodeTypedValue property isn't.
    >
    Can anyone please advise as this I would expect nodeValue to be populated.
    The nodeValue of element nodes in the DOM model is always null. With
    MSXML there is property named 'text' which gives you the text content of
    a node so in case of an element
    <tL>A</tL>
    to text property is "A".

    --

    Martin Honnen --- MVP XML

    Comment

    • Adam David Moss

      #3
      Re: ServerXMLHTTP and nodeValue versus nodeTypedValue

      That's got me confused - I have other bits of code that define objects of
      type MSXML.DOMDocume nt and the nodeValue works as expected?

      Regards.



      "Martin Honnen" <mahotrash@yaho o.dewrote in message
      news:e4WTyTr1IH A.3756@TK2MSFTN GP04.phx.gbl...
      Adam David Moss wrote:
      >
      >Long time since I've done some proper coding in ASP and I've hit a wee
      >snag that has got me baffled. Well two actually but the other is to do
      >with running pages under Sun ASP so we'll not go there! Anyway, I
      >digress...
      >>
      >I've cobbled together some code as shown below (removed error checking
      >etc for simplicity). This uses ServerXMLHTTP to grab an XML file off a
      >remote server. When querying the result, however, the nodeValue property
      >is null whereas the nodeTypedValue property isn't.
      >>
      >Can anyone please advise as this I would expect nodeValue to be
      >populated.
      >
      The nodeValue of element nodes in the DOM model is always null. With MSXML
      there is property named 'text' which gives you the text content of a node
      so in case of an element
      <tL>A</tL>
      to text property is "A".
      >
      --
      >
      Martin Honnen --- MVP XML
      http://JavaScript.FAQTs.com/

      Comment

      • Anthony Jones

        #4
        Re: ServerXMLHTTP and nodeValue versus nodeTypedValue

        "Adam David Moss" <no@email.addre sswrote in message
        news:uRs3qPu1IH A.4912@TK2MSFTN GP03.phx.gbl...
        That's got me confused - I have other bits of code that define objects of
        type MSXML.DOMDocume nt and the nodeValue works as expected?
        >
        nodeValue and nodeTypedValue despite appearances are very different
        properties.


        nodeValue is a standard DOM property which returns a nodes value. Node
        types such as an attribute or a text node have a value. Elements however do
        not have a value they only have child nodes of various types.

        Hence in your original code you could include this line:-

        Response.Write
        ..responseXML.d ocumentElement. firstChild.firs tChild.firstChi ld.nodeValue

        and it would return a value. Whilst a simple XML element that only contains
        text may appear that it should have the value of its text it is infact an
        element that has a single child node. The child node is a text node and its
        the text node that has a value.



        OTH nodeTypedValue is an MS enhancement which allows a simple element to
        carry a value which may be typed. The element may carry a dt:dt attribute
        (where dt is alias for the "urn:schema s-microsoft-com:datatypes" namespace)
        that defines a data type. The nodeTypedValue returns a variant with a VT
        type corresponding to the dt:dt attribute. If dt:dt is not present string
        is assumed. The value of the property is drawn from the text of the
        element.


        Hope this clarifies things.



        --
        Anthony Jones - MVP ASP/ASP.NET


        Comment

        • Martin Honnen

          #5
          Re: ServerXMLHTTP and nodeValue versus nodeTypedValue

          Adam David Moss wrote:
          That's got me confused - I have other bits of code that define objects
          of type MSXML.DOMDocume nt and the nodeValue works as expected?
          Well nodeValue makes sense for text nodes, cdata section nodes,
          attribute nodes, comment nodes, processing instruction nodes. The
          "expected" value however for element nodes or document nodes is null
          (respectively Nothing in VBScript), see

          which lists what nodeValue gives for the different types of nodes.


          --

          Martin Honnen --- MVP XML

          Comment

          • Anthony Jones

            #6
            Re: ServerXMLHTTP and nodeValue versus nodeTypedValue

            "Martin Honnen" <mahotrash@yaho o.dewrote in message
            news:O1eYhU41IH A.4492@TK2MSFTN GP02.phx.gbl...
            Adam David Moss wrote:
            That's got me confused - I have other bits of code that define objects
            of type MSXML.DOMDocume nt and the nodeValue works as expected?
            The "expected" value however for element nodes or document nodes is null
            (respectively Nothing in VBScript),
            Getting a little .NET parlance mixed in there ;)

            Its Null in VBScript also (nodeValue returns a variant).


            --
            Anthony Jones - MVP ASP/ASP.NET


            Comment

            • Martin Honnen

              #7
              Re: ServerXMLHTTP and nodeValue versus nodeTypedValue

              Anthony Jones wrote:
              "Martin Honnen" <mahotrash@yaho o.dewrote in message
              >The "expected" value however for element nodes or document nodes is null
              >(respectivel y Nothing in VBScript),
              >
              Getting a little .NET parlance mixed in there ;)
              >
              Its Null in VBScript also (nodeValue returns a variant).
              Thanks for correcting. It seems .NET has spoiled the few VBScript
              experiences I ever had.



              --

              Martin Honnen --- MVP XML

              Comment

              • Adam David Moss

                #8
                Re: ServerXMLHTTP and nodeValue versus nodeTypedValue

                Thanks guys that makes sense now!

                Cheers.




                "Martin Honnen" <mahotrash@yaho o.dewrote in message
                news:%23kxN4j61 IHA.4188@TK2MSF TNGP04.phx.gbl. ..
                Anthony Jones wrote:
                >"Martin Honnen" <mahotrash@yaho o.dewrote in message
                >
                >>The "expected" value however for element nodes or document nodes is null
                >>(respective ly Nothing in VBScript),
                >>
                >Getting a little .NET parlance mixed in there ;)
                >>
                >Its Null in VBScript also (nodeValue returns a variant).
                >
                Thanks for correcting. It seems .NET has spoiled the few VBScript
                experiences I ever had.
                >
                >
                >
                --
                >
                Martin Honnen --- MVP XML
                http://JavaScript.FAQTs.com/

                Comment

                Working...