Cannot find the p node with selectNodes

Discussion in 'ASP General' started by Robert Mark Bram, Mar 1, 2004.

  1. Hi All!

    In the code below, I am reading in an xhtml document and attempting to use
    selectNodes to find a <p id="rmb"> node..

    But the result is:
    2 - */*
    0 - */p[@id = "rmb"]

    Can anyone suggest what I am doing wrong?

    Any ideas would be most appreciated!

    Rob
    :)


    ====
    xmlTest.asp
    ====
    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    <%

    var xmlDocument = Server.CreateObject("Msxml2.DOMDocument.3.0");
    xmlDocument.async = false;
    xmlDocument.setProperty ("ServerHTTPRequest", true);
    xmlDocument.setProperty ("SelectionLanguage", "XPath");
    var loaded = xmlDocument.load(Server.MapPath("basic.htm"));

    if (loaded)
    {
    var editable = xmlDocument.selectNodes ("*/*");
    Response.write (editable.length + " - " + editable.expr + "<br>");

    var editable = xmlDocument.selectNodes ("*/p[@id = \"rmb\"]");
    Response.write (editable.length + " - " + editable.expr + "<br>");
    } // end if

    %>



    ====
    basic.htm
    ====
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>
    <body>
    <h1>Heading</h1>
    <p>Body Text</p>
    <p id="rmb">Body Text</p>
    </body>
    </html>
    Robert Mark Bram, Mar 1, 2004
    #1
    1. Advertising

  2. Robert Mark Bram

    Chris Barber Guest

    Try:

    //p[@id='rmb']

    Chris.


    "Robert Mark Bram" <none> wrote in message
    news:404344d4$0$16103$...
    Hi All!

    In the code below, I am reading in an xhtml document and attempting to use
    selectNodes to find a <p id="rmb"> node..

    But the result is:
    2 - */*
    0 - */p[@id = "rmb"]

    Can anyone suggest what I am doing wrong?

    Any ideas would be most appreciated!

    Rob
    :)


    ====
    xmlTest.asp
    ====
    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    <%

    var xmlDocument = Server.CreateObject("Msxml2.DOMDocument.3.0");
    xmlDocument.async = false;
    xmlDocument.setProperty ("ServerHTTPRequest", true);
    xmlDocument.setProperty ("SelectionLanguage", "XPath");
    var loaded = xmlDocument.load(Server.MapPath("basic.htm"));

    if (loaded)
    {
    var editable = xmlDocument.selectNodes ("*/*");
    Response.write (editable.length + " - " + editable.expr + "<br>");

    var editable = xmlDocument.selectNodes ("*/p[@id = \"rmb\"]");
    Response.write (editable.length + " - " + editable.expr + "<br>");
    } // end if

    %>



    ====
    basic.htm
    ====
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>
    <body>
    <h1>Heading</h1>
    <p>Body Text</p>
    <p id="rmb">Body Text</p>
    </body>
    </html>
    Chris Barber, Mar 1, 2004
    #2
    1. Advertising

  3. Robert Mark Bram

    Pravin Patil Guest

    Try
    //*[name(.) = 'p' and @id = 'rmb'

    Cheers

    Pravin Pati
    Microsoft(R) MVP
    Pravin Patil, Mar 1, 2004
    #3
  4. Hi Chris,

    Thank you for the response.

    > //p[@id='rmb']


    This did not work.. it gave me:
    0 - //p[@id='rmb']

    I am at a loss to explain why. :-\

    Rob
    :)
    Robert Mark Bram, Mar 1, 2004
    #4
  5. Hi Pravin,

    Thank you very much - this worked!
    > //*[name(.) = 'p' and @id = 'rmb']


    The result I obtained:
    0 - //p[@id='rmb']
    1 - //*[name(.) = 'p' and @id = 'rmb']

    Do you happend to know why the first one (Chris Barber's suggestion) deosn't
    work for me?

    Thank you again!

    Rob
    :)
    Robert Mark Bram, Mar 1, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,375
  2. =?Utf-8?B?Sm9l?=

    SelectNodes vs. GetElementsByTagName

    =?Utf-8?B?Sm9l?=, Nov 2, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    41,105
    =?Utf-8?B?Sm9l?=
    Nov 2, 2005
  3. Tjerk Wolterink
    Replies:
    2
    Views:
    1,392
    Dimitre Novatchev
    Aug 24, 2006
  4. RKS

    Sarissa selectNodes

    RKS, Apr 3, 2006, in forum: Javascript
    Replies:
    1
    Views:
    87
  5. John Smith

    x-browsercize selectNodes + transformNode

    John Smith, Feb 20, 2007, in forum: Javascript
    Replies:
    3
    Views:
    193
    John Smith
    Feb 20, 2007
Loading...

Share This Page