Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT 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, 01:35 PM
Registered User
 
Join Date: Jul 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default having trouble with nodes/children

hey all--

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

Code:
<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.

Code:
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
 
Old July 13th, 2007, 01:49 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Since you chose to post this question on an XSLT forum, the obvious response is: why not do it in XSLT?

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old July 13th, 2007, 04:16 PM
Registered User
 
Join Date: Jul 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by mhkay
 Since you chose to post this question on an XSLT forum, the obvious response is: why not do it in XSLT?

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
thats really not helpful, michael. where do you suggest i post this query if you say it will not get answered here?
 
Old July 13th, 2007, 04:52 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Sorry not to be helpful, but I don't even recognize the programming language you are writing in, so how would I know where to get help with it?

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
help with nodes/children bmmayer XML 0 July 13th, 2007 05:04 PM
MDI Children angelboy C# 2005 5 June 28th, 2007 06:08 AM
match only first level children sgruhier XSLT 1 February 22nd, 2005 05:12 AM
Determining the number of children raoulvb XSLT 2 November 30th, 2004 10:50 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.