• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

XML to HTML (Distinct between identical params)

Participant ,
May 16, 2009 May 16, 2009

Copy link to clipboard

Copied

Hi all

I'm trying to display the content of a XML file into a HTML page. Unfortunately in the XML structure contains the parameter 'falsch' twice per 'frage' (see XML below). I still would like to display the different values in 'falsch' (see code below).
Is there an easy way to distinct from 'falsch' and 'falsch'? Please note that this is just an extract from the XML file otherwise I would have renamed the param 'falsch' 😉

Thank you very much!


<!--- My XML file called d.xml --->

<?xml version="1.0" encoding="ISO-8859-1" ?>
<website>
    <frage>
        <frage_nr>120012</frage_nr>
        <frage_text><![CDATA[ Bis und mit welcher Segelfläche ist bei einem Segelschiff kein Führerausweis erforderlich (Abweichungen für einzelne Grenzgewässer ausgenommen)?]]></frage_text>
        <frage_bild />
        <gesetz><![CDATA[ Ziff. 402.2 (BSV 78) (BSO 12.01)]]> </gesetz>
        <gesetzlink />
        <richtig><![CDATA[ Wenn die Segelfläche weniger als 15m² beträgt]]> </richtig>
        <falsch><![CDATA[ Darüber bestehen keine Vorschriften]]> </falsch>
        <falsch><![CDATA[ Wenn die Segelfläche mehr als 15m² beträgt]]> </falsch>
    </frage>
    <frage>
        <frage_nr>120024</frage_nr>
        <frage_text><![CDATA[ Bis und mit welcher Motorenleistung ist kein Führerausweis erforderlich (Abweichungen für einzelne Grenzgewässer ausgenommen)?]]> </frage_text>
        <frage_bild />
        <gesetz><![CDATA[ Ziff. 402.2 (BSV 78), Ziff. 902.2 (BSO 12.01)]]></gesetz>
        <gesetzlink />
        <richtig><![CDATA[ Bis 6 kW]]></richtig>
        <falsch><![CDATA[ Bis 4,4 kW]]></falsch>
        <falsch><![CDATA[ Bis 6 PS]]></falsch>
    </frage>
</website>

<!--- My .cfm --->

<cfset link = ExpandPath('.') & "\d.xml" />
<cffile action="read" file="#link#" variable="xm" />
<cfset myxml = XmlParse(#xm#) />

<cfloop from="1" to="#ArrayLen(myxml.website.frage)#" index="i">
    #myxml.website.frage.frage_text.xmltext#<br>
    <font size="-6">
        (#myxml.website.frage.gesetz.xmltext#,
        #myxml.website.frage.gesetzlink.xmltext#)
    </font><br><br>
    <cfif len(myxml.website.frage.frage_bild.xmltext)><img src="fragen_pics/#myxml.website.frage.frage_bild.xmltext#" alt="" width="370" height="250" border="0"><cfelse></cfif>
    <br><br>
    #myxml.website.frage.richtig.xmltext#
    <hr width="100%" size="1" noshade style="margin-top: 35px;">
    #myxml.website.frage.falsch.xmltext#
    <hr width="100%" size="1" noshade style="margin-top: 35px;">
    #myxml.website.frage.falsch.xmltext#
</cfloop>      

TOPICS
Advanced techniques

Views

826

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 16, 2009 May 16, 2009

Copy link to clipboard

Copied

#myxml.website.frage+.falsch[1].xmltext# and

myxml.website.frage+.falsch[2].xmltext

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 16, 2009 May 16, 2009

Copy link to clipboard

Copied

Hi mack_

Sorry, did not help. CF throws the following error:

Invalid CFML construct found on line 116 at column 30.

ColdFusion was looking at the following text:

.

The CFML compiler was processing:

  • An expression beginning with myxml.website.frage, on line 116, column 10.This message is usually caused by a problem in the expressions structure.
  • The body of a cfoutput tag beginning on line 89, column 2.
  • The body of a cfoutput tag beginning on line 89, column 2.
The error occurred in ......: line 116
114 :         #myxml.website.frage.richtig.xmltext#
115 :         <hr width="100%" size="1" noshade style="margin-top: 35px;">
116 :         #myxml.website.frage+.falsch[1].xmltext#
117 :         <hr width="100%" size="1" noshade style="margin-top: 35px;">
118 :         #myxml.website.frage+.falsch[2].xmltext#

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 16, 2009 May 16, 2009

Copy link to clipboard

Copied

... and that's the way it works!!! Thanks again mack_

        #myxml.website.frage.falsch[1].xmltext#

        #myxml.website.frage.falsch[2].xmltext#

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 16, 2009 May 16, 2009

Copy link to clipboard

Copied

Hmm, it looks like the email-to-web interface changed

"myxml.website.frage+.falsch[1].xmltext" (frage open-bracket i

close-bracket) into "myxml.website.frage+.falsch[1].xmltext".

Mack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 16, 2009 May 16, 2009

Copy link to clipboard

Copied

LATEST

Testing, testing, does this look italic ?

Mack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation