Cannot find the p node with selectNodes

  • Thread starter Robert Mark Bram
  • Start date
R

Robert Mark Bram

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>
 
C

Chris Barber

Try:

//p[@id='rmb']

Chris.


"Robert Mark Bram" <none> wrote in message
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>
 
R

Robert Mark Bram

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
:)
 
R

Robert Mark Bram

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
:)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top