RE: [xsl] Using position predicate in XPath string within selectSingleNode DOM method

Subject: RE: [xsl] Using position predicate in XPath string within selectSingleNode DOM method
From: "Matthieu Ricaud" <matthieu.ricaud@xxxxxxx>
Date: Wed, 24 Nov 2004 12:00:19 +0100
Hi Pieter,

Thanks for your answering !
Unfortunately foo[.=3] doesn't work either.

I was using MSXML2.FreeThreadedDOMDocument as progId so I changed it to
"MSXML2.DOMDocument.3.0", but the result is the same
(I've also install the SP4 for MSXML 3.0)

Curisously I get it work when writing ITEM[1] (but not for ITEM[.=1])
When writing ITEM[2] or ITEM[.=2] it doesn't work anymore !

This is my asp page :

<%@ Language=VBScript %>
<%Response.Buffer=true%>
<%Response.contentType = "text/html"%>
<%Response.charset = "ISO-8859-1"%>
<%
Dim objXML
	set objXML= Server.CreateObject("MSXML2.DOMDocument.3.0")
	objXML.async = false
	objXML.load server.MapPath("test.xml")

Dim objNode
	Set objNode=objXML.documentElement.SelectSingleNode("ITEM[.=2]")

Response.write objNode.getAttribute("libelle")
%>

And the xml doc :
<?xml version="1.0"?>
<ROOT>
	<ITEM libelle="menu1" />
	<ITEM libelle="menu2" />
</ROOT>

My goal is to manipulate a specific node choosen by the user who just click
an HTML link for this node, the xsl I use to display all the node with link
get the full node Path which is send to the asp page...

Would it work using another XML parser ?
Any other solution ?

Matthieu.


-----Message d'origine-----
De : Pieter Reint Siegers Kort [mailto:pieter.siegers@xxxxxxxxxxx]
Envoyi : mercredi 24 novembre 2004 01:51
@ : xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Objet : RE: [xsl] Using position predicate in XPath string within
selectSingleNode DOM method


Hi Matthieu,

Try

Set objNode= objXML.selectSingleNode("foo[.=3]")

Obviously, using MSXML 3.0, objXML should be of type MSXML2.DOMDocument.3.0,
and objNode should be of type MSXML2.IXMLDOMNode.

HTH,
<prs/>

-----Original Message-----
From: Matthieu Ricaud [mailto:matthieu.ricaud@xxxxxxx]
Sent: Tuesday, November 23, 2004 10:20 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx; Hardy Merrill
Subject: [xsl] Using position predicate in XPath string within
selectSingleNode DOM method

Hi !

Does anybody know why I can't write something like this :

Set objNode= objXML.selectSingleNode("foo[3]")

(no node matched)

Whereas objNode= objXML.selectSingleNode("foo") works fine

foo[3] is the abreviation for foo[position()=3]

position() is a function, would that means that function are not allowed in
Xpath string within selectSingleNode

I've also tried with SelectNodes method, but I still have the same problem

I use ASP with DOM and my parser is MSXML3

Has anybody an explanation for this,

In advance Thanks,

Regards,

Matthieu.

Current Thread