Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML 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 July 13th, 2007, 05:04 PM
Registered User
 
Join Date: Jul 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default help with nodes/children

 hey all--

posted this in wrong forum before.

i'm new to XML--can someone take a look at this code for me? i'm trying to cycle through this structure below.


<item>
        <title></title>
        <link></link>
        <description></description>
        <guid isPermaLink="true"></guid>
        <pubDate></pubDate>
        <db:event>

          <db:title></db:title>
          <db:eventType></db:eventType>
          <db:abstract></db:abstract>
          <db:rsvp></db:rsvp>
          <db:host></db:host>
          <db:venue_name></db:venue_name>
          <db:address>

            <db:street></db:street>
            <db:city></db:city>
            <db:state></db:state>
            <db:country></db:country>
            <db:zipcode></db:zipcode>
          </db:address>
          <db:scheduledTime>

            <db:dateTime></db:dateTime>
            <db:length></db:length>
          </db:scheduledTime>
          <db:attendee_count></db:attendee_count>
          <db:guest_total></db:guest_total>
          <db:latitude></db:latitude>

          <db:longitude></db:longitude>
        </db:event>
      </item>



i want to pull data off the following tags: title, link, description, street, city, state, zip, dateTime, and venue_name.

this is the code as it stands right now.

req.onload = function() {

var response = req.responseXML;
var htmlContent = "<table class='btvTable'>";
var event = response.getElementsByTagName('item');

    for (var i=0; i<event.length; i++) {
        var pTitle = event[i].getElementsByTagName('title')[0];
        var pLink = event[i].getElementsByTagName('link')[0];
        var pDesc = event[i].getElementsByTagName('description')[0];
        var pEvent = event[i].getElementsByTagName('db:event').childNodes;
        var pVenue = pEvent.item(0);

        var pAddress = pEvent.getElementsByTagName('db:address');
                var pCity = pAddress.getElementsByTagName('db:city');
                var pState = pAddress.getElementsByTagName('db:state');
                var pZip = pAddress.getElementsByTagName('db:zip');

            var pScheduledTime = pEvent.getElementsByTagName('db:scheduledTime');
                var pTime = pScheduledTime.getElementsbyTagName('db:dateTime') ;

        htmlContent += "<tr><td style='border-bottom:1px dotted #919194'><a class='eventLink' href='"
                + pLink.firstChild.data
                + "' target='_blank'>"
                + pTitle.firstChild.data
                + "</a><br>"
                + "<br><br>"
                + "</td></tr>";
    }
htmlContent += "</table>";
document.getElementById("eventcontent").innerHTML = htmlContent;

}



-b





Similar Threads
Thread Thread Starter Forum Replies Last Post
having trouble with nodes/children bmmayer XSLT 3 July 13th, 2007 04:52 PM
MDI Children angelboy C# 2005 5 June 28th, 2007 06:08 AM
unique children detection rjonk XSLT 1 June 30th, 2006 11:20 PM
match only first level children sgruhier XSLT 1 February 22nd, 2005 05:12 AM
get all children nodes maratg XSLT 4 November 7th, 2003 02:07 PM





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