XML selectSingleNode Issue....

i'm trying to extract the data in black below using selectSingleNode

It works with everything else i'm extracting from the xml file, just not this....

Not working....

strXML(i) = strXML(i) & objNode.selectSingleNode ("Case/StatusUpdate").Text & "|"

<StatusUpdate>

  <Beh Id="2" Name="Nutrition" />
  <Met Id="38" Name="Unknown" />
  <Status Id="1" Name="Determined Readiness" />
  <StageChange Id="3" Name="Preparation" />
  <StatusDate>11/10/2004</StatusDate>
  </StatusUpdate>
 
Thanks....


Answer this question

XML selectSingleNode Issue....

  • Evgeny Popov

    Hi,

    .Net framework xml library of name space "Xml" has XmlDocument which has this SelectSingleNode method but it has not "TEXT" property.

    You can either use objNode.selectSingleNode ("Case/StatusUpdate").InnerText  or objNode.selectSingleNode ("Case/StatusUpdate").Value

    If the element has no text and only child elements like in your case for StatusUpdate element, then InnerText will give "" [blank string] and Value will give "null" as returned value.

    If you want to get all xml elements under StatusUpage then you can use objNode.selectSingleNode ("Case/StatusUpdate").InnerXml which will give you the inner xml as string.

    HTH,

     

     



  • Eric T.

    I guess he is using MSXML parser and not System.Xml. It is pretty evident that he is using .selectSingleNode (with lower s) and .text both of which are applicable to MSXML.

    As Oleg mentioned there is no Case element so your xpath is incorrect. Try the below code (assuming javascript) to get the data in black.

    var Status = objNode.selectSingleNode ("StatusUpdate");
    var BehId  = Status.selectSingleNode("Beh").attributes.getNamedItem("Id").text;  //or .value
    var BehName= Status.selectSingleNode("Beh").attributes.getNamedItem("Name").text;

    // .... and so on
    var StatusDate = Status.selectSingleNode("StatusDate").text;

    Thanks
    Pranav Kandula


  • Scott P. Lane

    1. I don't see Case element in your XML

    2. StatusUpdate element has no text content, just children elements.



  • XML selectSingleNode Issue....