Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with multiple tags in XML

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi there,

I have a problem with more than one tag in XML. For exmplae my XML-file would be:

<site>
<text place=&quot;center&quot;>Hello!</text>
</site>

My XSL-file transform it into <p align=&quot;center&quot;>Hello!</p>
But when I have this:

<site>
<text place=&quot;center&quot;>Hello!</text>
<text place=&quot;right&quot;>My name is Sander</text>
</site>

In this case the XSL-file will transform this into:

<p align=&quot;center&quot;>Hello!</p>
<p align=&quot;right&quot;>Hello!</p>

Notice that the value of the text-tag will be shown twice. And also that this doesn't happen with the attribute &quot;place&quot;. I tried lots of things with XSL, like:

<xsl:for-each select=&quot;site&quot;>
<xsl:value-of select=&quot;text&quot;/>
</xsl:for-each>

But this doesn't work and now I'm out of ideas. Is there anyone to solve this difficult problem? I'll thank you for reading this problem and I hope you will answer it!!

Thnx in advance,

Sander K
 
Hi Sander K,

I had once a sort of problem like this. Mayby you should solve this like this:

XML-file:
<site>
<text>
<a><b>hello</b></a>
<a><b>my name is jack</b></a>
</text>
</site>


XSL-file:
<xsl:template match=&quot;site&quot;>
<xsl:for-each select=&quot;text&quot;>
<p><xsl:value-of select=&quot;a&quot;/></p>
</xsl:for-each>
</xsl:template>


This should work, if I spelled everything right. Mayby a little complex, but it worked for me.

Mr Dev
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top