Wrox Programmer Forums
|
BOOK: Professional Ajax ISBN: 978-0-471-77778-6
This is the forum to discuss the Wrox book Professional Ajax by Nicholas C. Zakas, Jeremy McPeak, Joe Fawcett; ISBN: 9780471777786
Important: For the new 2nd edition of this book, please post here instead: [url="http://p2p.wrox.com/forum.asp?FORUM_ID=307"]http://p2p.wrox.com/forum.asp?FORUM_ID=307[/url]
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Ajax ISBN: 978-0-471-77778-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 19th, 2006, 12:17 PM
Registered User
 
Join Date: May 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default SelectNodes, SelectSingleNode weirdness

Hello,

I'm seeing some weirdness that may just because i've been staring at it entirely too long. I have some xml that has a section similar to this

<link currentlink="Yes" linkname="Current Link">
    <leased_bw unit="Khz" value="3549.9"></leased_bw>
    <month_bw savings="1468.9103448275864" percent="13.8" payback_period="10.211651141826922"></month_bw>

</link>

<link currentlink="No" linkname="New Link">
    <leased_bw unit="Khz" value="3060.2" current="3549.9"></leased_bw>
    <month_bw savings="1468.9103448275864" percent="13.8" payback_period="10.211651141826922"></month_bw>
</link>

I have some code that looks like this:

var nodeLinks = oXmlDomCalcNetwork.selectNodes("//linkcalc//link");
    var i;
    var nodeLink;
    var nodeLink2;

        nodeLink = nodeLinks[0];

            document.getElementById('txtLinkName').value = nodeLink.getAttribute("linkname");

            nodeLink2 = nodeLinks[1];

            document.getElementById('text1').value = nodeLink2.xml;

            var nodeLeasedBWNew = nodeLink2.selectSingleNode("//leased_bw");
            document.getElementById('txtNewLinkLB').value = nodeLeasedBWNew.getAttribute("value");

Nodelink works fine, i can parse out values from the XML just fine. nodelink2 works partially. I am writing out the conents of it, and it is parsing the correct nodes from the XML, but when i try to get the "value" attribute, i get the value attribute from nodelinks[0] instead of nodelink[1].

I've downloaded the latest zxml update.. and still no luck. I cant see what i'm doing wrong..

Any ideas?



 
Old October 19th, 2006, 12:39 PM
Registered User
 
Join Date: May 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I got around it, I still don't know what i did wrong originally. But i changed it to:


nodelink2 =oXmlDomCalcNetwork.selectSingleNode("//linkcalc//link[2]//month_bw[1]");

 document.getElementById('txtNewLinkAB').value = nodelink2.getAttribute("value");

or similar, and it seems to be working fine.


thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
SelectSingleNode throwing exception: anup_daware .NET Framework 2.0 1 February 3rd, 2008 12:04 PM
C# XML--SelectSingleNode/SelectNodes is failing. gijomk C# 1 August 29th, 2006 09:48 AM
C# XML--SelectSingleNode/SelectNodes is failing. gijomk XML 2 August 28th, 2006 03:28 AM
XML Namespace and ASP SelectNodes werD420 Classic ASP XML 1 August 13th, 2005 04:41 AM
MSXML - SelectNodes and XPath billy_bob_the_3rd Beginning VB 6 2 March 10th, 2005 06:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.