Click to See Complete Forum and Search --> : Displaying repeated XML elements in HTML


Zyjil
05-14-2004, 10:28 AM
Hi. I am making a trial XML database to learn about XML, and have come across a small hitch!

Here is a segment of the XML file I have produced:

<artwork>
<title>American Gothic</title>
<artist>
<name>Grant Wood</name>
<nationality>American</nationality>
<birth>1891</birth>
<death>1942</death>
</artist>
<description>
<content>
<para>Grant Woods American Gothic caused a stir...</para>
<para>American Gothic remains one of the most...</para>
</content>
</description>
</artwork>

(It has a root node 'artcollection', and more fields and records).

My problem is that when I try and display this in HTML, I cannot access the 'para' field in 'content' (it displays nothing). This is the code segment I *think* should work:

<xml src="art.xml" id="xmldso" async="false"></xml>
<table dataFld="CONTENT" dataSrc="#xmldso">
<tr>
<td><span datafld="PARA"></span></td>
</tr>
</table>

This works if there is only one 'para' node, but obviously it is desirable to have more than one paragraph in each description.

How can I display these repeated elements? :confused:

Thanks in advance,
Paul

Khalid Ali
05-14-2004, 11:00 AM
Try using standard DOM to read XML document rather then using MS specific code,you will have a better chance of getting help here or on line in general.

Zyjil
05-15-2004, 08:15 AM
Hello.

I found that When you bind data using the XML data source object, an automatic field called $Text is created. It contains the items in that record, concatenated. MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/htm/xml_concepts2_7ook.asp)

So the solution to my problem was to access the $Text field for the nodes I was trying to display. (I have my doubts over whether this is a cross-browser solution, but it works for me :) )