[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XPath problem with selectSingleNode in MSXML4


selectsinglenode
>> getAttribute returns a string while selectSingleNode returns
>> an object

Yes! Got it now:

 var href = xmldoc.selectSingleNode("/config/link[@default]/@href").value;

Thanks.


--- Dare Obasanjo <dareo@m...> wrote:
> > -----Original Message-----
> > From: John Sands [mailto:wonkowatson@y...] 
> > Sent: Sunday, April 07, 2002 8:46 PM
> > To: xml-dev@l...
> > Subject:  XPath problem with selectSingleNode in MSXML4
> > 
> > 
> > I have a file called config.xml like this:
> > 
> >  <?xml version="1.0"?>
> >  <config>
> >   <link href="tree.asp"/>
> >   <link href="search.asp" default="true" />
> >  </config>
> > 
> > This Javascript ASP code finds the href with the 
> > "default=true" attribute:
> > 
> >  var xmldoc = new ActiveXObject("MSXML2.DOMDocument.4.0");
> >  xmldoc.async = false;  xmldoc.load(Server.MapPath("config.xml"));
> >  xmldoc.setProperty("SelectionLanguage", "XPath");
> >  var defaultpage = xmldoc.selectSingleNode("/config/link[@default]");
> >  var href = defaultpage.getAttribute("href");
> > 
> > My question is, why doesn't this code find it as well?
> > 
> >  var xmldoc = new ActiveXObject("MSXML2.DOMDocument.4.0");
> >  xmldoc.async = false;  xmldoc.load(Server.MapPath("config.xml"));
> >  xmldoc.setProperty("SelectionLanguage", "XPath");
> >  var href = xmldoc.selectSingleNode("/config/link[@default]/@href");
> > 
> 
> The latter code does find it as well. The following code works fine for
> me 
> 
>  var xmldoc = new ActiveXObject("MSXML2.DOMDocument.4.0");
>  xmldoc.async = false;   
>  xmldoc.loadXML("<config><link href=\"tree.asp\"/><link
> href=\"search.asp\" default=\"true\" /></config>");
>  WScript.Echo(xmldoc.xml);  
>  xmldoc.setProperty("SelectionLanguage", "XPath");
>  var defaultpage = xmldoc.selectSingleNode("/config/link[@default]");
>  var href = defaultpage.getAttribute("href");
>  WScript.Echo("1: " + href);
>  href = xmldoc.selectSingleNode("/config/link[@default]/@href");
>  WScript.Echo("2: " + href.value);
> 
> when executed using Windows scripting host. The difference in behavior
> is because getAttribute returns a string while selectSingleNode returns
> an object.  
> 
> Hope this helps. 
> 
> PS: Ignore my prior offlist email, this is NOT a bug. 
> 
> -- 
> PITHY WORDS OF WISDOM 
> A journey of a thousand miles begins with a cash advance.
>  
> This posting is provided "AS IS" with no warranties, and confers no
> rights. 
> You assume all risk for your use. (c) 2002 Microsoft Corporation. All
> rights reserved.


__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.