Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Senior Member
    Join Date
    Aug 2006
    Posts
    131
    Member #
    13656
    Check out these links

    http://www.prudentialct.com/specialp...aa_sub_xml.asp
    http://www.prudentialct.com/js/xmlparser.js
    http://www.prudentialct.com/xml/aa.xml

    Something funky is going on with it...

    Bascially what I'm doing is creating a table based on xml results. I set up a loop to cycle through all the XML and pull out any relevant information. If a record contains a blank field it replaces it with a "-" sign. The thing that is happening though is that all information that is actually there appears at the top of the page and all the "-" appears at the bottom. The xml file is okay and the xml parser is alright, but it looks like I'm building the array wrong. Or reading it wrong for that matter?

    I actually use try/catch statements in the loop if that has any bearing... For some reason it seems as if the try/catch loop restarts the for loop when encountering an error.

    What should I do?
    Christopher Carvache
    Web Developer / SEO
    Northeast Web Design
    +1.860.906.7802

  2.  

  3. #2
    Senior Member
    Join Date
    Aug 2006
    Posts
    131
    Member #
    13656
    You know what? I figured it out...

    Basically the statement that I needed to is supposed to be written like this...

    Code:
    complex[d] = xmlDoc.getElementsByTagName('aacommunities')[d].getElementsByTagName('complex')[0].childNodes[0].nodeValue;
    The way it was before was wrong

    Code:
    complex[d] = xmlDoc.getElementsByTagName('complex')[d].childNodes[0].nodeValue;

    The wrong method only builds the arrays based on the number of tags in the 'complex' array and doesn't really test to see if there is a 'complex' tag within its parent 'aacommunities' tag.
    Christopher Carvache
    Web Developer / SEO
    Northeast Web Design
    +1.860.906.7802

  4. #3
    Junior Member
    Join Date
    Aug 2007
    Posts
    6
    Member #
    15662
    xmlDoc.getElementsByTagName works, but using the DOM, I use xmlDoc.getElementsByID("IDNAME") more.

    Get used to the DOM (document object model) for javascript. It works well.

    Bruce

  5. #4
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Right, but in this case it looks like the way the script works isn't fit for getElementById.

  6. #5
    Senior Member hyperair's Avatar
    Join Date
    May 2005
    Posts
    452
    Member #
    9892
    What Shadowfiend said, and it's getElementById, not getElementsById. An ID is unique (supposedly anyway), and hence you won't have "elements" with the same id. Another thing is.. while document.getElementById() works in DOM when you're accessing page data, it does not work when you're parsing XML data from XMLHTTPRequest. That's why getElementsByTagName was used in the script shown.
    Hyperair


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 02:05 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com