So, "//" should probably be used once to get at the root node?  What other
methods are faster than using the "//" xpath statement?

In my code I used the following effectively:
<cfscript>
 nodeOffer_Id = service.selectSingleNode("Offer_Id");
 Offer_Code = service.selectSingleNode("Offer_Id/@Offer_Code");
 Offer_Code = Offer_Code.text;
</cfscript>

Your code also worked the same.  Thanks!
Carl

----- Original Message -----
From: "Edward Smith" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Tuesday, July 10, 2001 10:43 AM
Subject: Re: MSXML, XML, outputting attributes?


> Just a note, try to avoid using "//" in xpath - its has serious
> performance problem potential.
>
> Its essentially saying, "scan the whole DOM and look for any 'book'
> nodes."  I don't think that this is what you want.
>
> In your real code, you are already in the "Service_Availability" node,
> so you don't need to use "//Offer_ID"  Just use "Offer_ID", as its a
> direct child node of the Service Availability.  This will prevent the
> parser from starting at the top of the DOM again.  Also, on my MSXML 3
> SP1, if you use //Offer_ID for the xpath statement, I always get the
> first offer_id, which makes sense, since it matches the first one it
> finds in the DOM, every time.
>
> So, the bit of code would be:
> <cfscript>
>      i=i+1;
>      nodeOffer_Id = service.selectSingleNode("Offer_Id");
>      Offer_Id = nodeOffer_Id.text;
>      Offer_Code = nodeOffer_Id.getAttribute("Offer_Code");
> </cfscript>
>
> Merging in the previous suggestion:
>
> <cfscript>
>      i=i+1;
>      nodeOffer_Id = service.selectSingleNode("Offer_Id/@Offer_Code");
>      Offer_Code = nodeOffer_Id.text;
> </cfscript>
>
>
> Carl wrote:
> >
> > Thanks, Brett!  That worked pefect.
> > Carl
> > ----- Original Message -----
> > From: "Brett Suwyn" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Cc: <[EMAIL PROTECTED]>
> > Sent: Monday, July 09, 2001 3:31 PM
> > Subject: RE: MSXML, XML, outputting attributes?
> >
> > > You can access them directly with XPath or the GetNamedItem method
> > > called on the node.
> > >
> > > For example (using XPath):
> > >
> > > <cfscript>
> > > iBookID = xmlDoc.selectSingleNode("//book/@id");
> > > </cfscript>
> > >
> > >
> > > Brett Suwyn
> > > mailto:[EMAIL PROTECTED]
> > > http://forums.siteobjects.com
> > >
> > > |>   -----Original Message-----
> > > |>   From: Carl [mailto:[EMAIL PROTECTED]]
> > > |>   Sent: Monday, July 09, 2001 3:08 PM
> > > |>   To: CF-Talk
> > > |>   Subject: MSXML, XML, outputting attributes?
> > > |>
> > > |>
> > > |>   Hi,
> > > |>   How do I output attributes from an XML document? I have
> > > |>   tried using the following example on Microsofts website.
> > > |>
> > > |>   MS EXAMPLE:
> > > |>   var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
> > > |>   var nodeBook, sIdValue;
> > > |>   xmlDoc.async = false;
> > > |>   xmlDoc.load("books.xml");
> > > |>   nodeBook = xmlDoc.selectSingleNode("//book");
> > > |>   sIdValue = nodeBook.getAttribute("id")
> > > |>   alert(sIdValue);
> > > |>
> > > |>   Thanks!!
> > > |>   Carl
> > > |>
> > >
> > >
> >
> >
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to