Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / May 2005



Tip: Looking for answers? Try searching our database.

XML / XSLT / CF

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
[lb]Sonix - 30 May 2005 13:33 GMT
Hi Everyone,

I'm trying to parse my XML File with ColdFusion and I've already made an
Object like:

<cffile action="read" file="C:\myxmldoc.xml" variable="XMLFileText">
<cfset myXMLDocument=XmlParse(XMLFileText)>
<cfoutput>#toString(myXMLDocument)#</cfoutput>

my Problem is: I only want to output some childs not the whole XML-File.
I could tranform it with XSLT, but my <xsl:template>...</xslt:template> as xls
String doesn't work.

Thx 4 help,
Sonix
RoBsTaMaCk - 31 May 2005 21:34 GMT
I'm going to use the latest virus alerts feed from .link.XmlText# (where x is
the item number you want)

From here, you can create a simple loop that changes the value of X and
outputs all the items.  Even if you're only retrieving one node of data (and
not a series), hopefully the steps described above should help you determine
how to locate and reference the nodes you need.

<!--- // Retrieve XML file for latest virus alerts // --->
<cfhttp    url="http://www.sophos.com/virusinfo/infofeed/tenalerts.xml"
        method="GET"
        timeout="15">
</cfhttp>

<!--- // Trim whitespace and parse XML // --->
<cfscript>
    XMLContent = trim(cfhttp.filecontent);
    XMLContent = XMLParse(XMLContent);
</cfscript>

<!--- // Output ONLY THE FIRST 5 alerts // --->
<cfoutput>
    <cfloop from ="1" to="5" index="i">
        <a href="#XMLContent.RDF.item[i].link.XmlText#"
target="_blank">#XMLContent.RDF.item[i].title.XmlText#</a><br>
    </cfloop>
</cfoutput>
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.