Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. selectNode returns 0 if XML contains '&' [modified]

selectNode returns 0 if XML contains '&' [modified]

Scheduled Pinned Locked Moved XML / XSL
javascriptxmlhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arindam Tewary
    wrote on last edited by
    #1

    If I have a XML like this which I am loading into javascript using DomDocument object. Please note that this XML is having an "ampersand".

    <DataSet>
    <Row>
    <NDOCUMENTID>499</NDOCUMENTID>
    <TDESCRIPTION>my **&**amp; god</TDESCRIPTION>
    <TDISPLAYNAME>my god</TDISPLAYNAME>
    <TTITLE>my god</TTITLE>
    <NPARENT_DOC_ID>0</NPARENT_DOC_ID>
    <NPARENT_FOLDER_ID>496</NPARENT_FOLDER_ID>
    </Row>
    <Row>
    <NDOCUMENTID>501</NDOCUMENTID>
    <TDESCRIPTION>Level 2Folder</TDESCRIPTION>
    <TDISPLAYNAME>Level 2Folder</TDISPLAYNAME>
    <TTITLE>Level 2Folder</TTITLE>
    <NPARENT_DOC_ID>0</NPARENT_DOC_ID>
    <NPARENT_FOLDER_ID>500</NPARENT_FOLDER_ID>
    </Row>
    </DataSet>

    After loading into javascript DomDocument object selectNodes() returns 0.

    var objXML = new ActiveXObject("MSXML2.DomDocument");
    . . . . // some code to load the above XML into objXML
    objFolderNodes = objXML.selectNodes("//DataSet/Row[NPARENT_FOLDER_ID = '496']");

    alert("objFolderNodes.length :"+objFolderNodes.length);

    Please note that if I remove the '&', above code working fine. Any help is appreciated. Thanks in advance.

    Thanks, Arindam D Tewary

    modified on Monday, February 2, 2009 3:37 AM

    L 1 Reply Last reply
    0
    • A Arindam Tewary

      If I have a XML like this which I am loading into javascript using DomDocument object. Please note that this XML is having an "ampersand".

      <DataSet>
      <Row>
      <NDOCUMENTID>499</NDOCUMENTID>
      <TDESCRIPTION>my **&**amp; god</TDESCRIPTION>
      <TDISPLAYNAME>my god</TDISPLAYNAME>
      <TTITLE>my god</TTITLE>
      <NPARENT_DOC_ID>0</NPARENT_DOC_ID>
      <NPARENT_FOLDER_ID>496</NPARENT_FOLDER_ID>
      </Row>
      <Row>
      <NDOCUMENTID>501</NDOCUMENTID>
      <TDESCRIPTION>Level 2Folder</TDESCRIPTION>
      <TDISPLAYNAME>Level 2Folder</TDISPLAYNAME>
      <TTITLE>Level 2Folder</TTITLE>
      <NPARENT_DOC_ID>0</NPARENT_DOC_ID>
      <NPARENT_FOLDER_ID>500</NPARENT_FOLDER_ID>
      </Row>
      </DataSet>

      After loading into javascript DomDocument object selectNodes() returns 0.

      var objXML = new ActiveXObject("MSXML2.DomDocument");
      . . . . // some code to load the above XML into objXML
      objFolderNodes = objXML.selectNodes("//DataSet/Row[NPARENT_FOLDER_ID = '496']");

      alert("objFolderNodes.length :"+objFolderNodes.length);

      Please note that if I remove the '&', above code working fine. Any help is appreciated. Thanks in advance.

      Thanks, Arindam D Tewary

      modified on Monday, February 2, 2009 3:37 AM

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      I did not verified this but my memory is that an entity is required for that character to be handled correctly by parsers etc. http://www.google.com/#hl=en&q=xml+entity&btnG=Google+Search&aq=f&oq=xml+entity&fp=3WTwdsC3GPc[^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups