Looping throught XML childnodes without JavaScript
Hi there
A quick one (I think).
I am kind of new to XML and I'm kind of stuck on something that may be trivial to most of you.
I have something like this:
eg 1:
***********
<book>
<table_of_content>List of topics:</table_of_content>
<content>
<title>title one</title>
<title>title two</title>
<title>title three</title>
<title>title four</title>
</content>
</book>
***********
How will I display on the site page something like
____
List of topics:
1. title one
2. title two
3. title three
4. title four
____
I mean how would I do something like looping through the elements (what I am mostly interested is displaying the values of elements with the same name, i.e. title,title,title,etc) but using only XML, XSD, XSLT/XPath, without using JavaScript or Pearl or similar?
In my naivity and misunderstanding of how XML and XSLT/XPath works I thought something like
<xsl:for-each select="club_members">
<xsl:value-of select="name"/>
<xsl:value-of select="email"/>
</xsl:for-each>
would actually loop through the children of some parent element.
Would you,guys, be so kind and put toghether a tiny combination of the three (XML, XSLT/XPath, XSD) that might show me how these work toghegher towards the result I mentioned before? But, again, is there any way this can be done without using JS or other prog. languages?
Thanks a lot, Dave, for your reply!
Some time ago I received an assignment that stated the code structure should not be modified but to work and find a solution to display on the values from the code as is. And the code did look something like both the one displayed on both e.g.1 and e.g.2 in my message. It confused de heck out of me. I spent some time on some of the classic tutorials on the net (things like w3schools, tizag, etc) but I just can not find a solution. I did write something like the following which displayed ok in Internet Explorer but not in Firefox:
They look odd to me too. But I should say that I tried to appreciate XSLT, but realistically I pretty much hate it. I find it far easier to parse and display XML with PHP's SimpleXML interface, and that's what I do*.
Dave
* as a hobby developer. I am not doing this for a living where it might somehow actually matter.
Cheers, Dave. I'll keep on playing with it maybe I bump into something that will do it. I really wish I could use some third party solution to this 'coz I'm getting tired of it now.
Bookmarks