Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question transfrom xml to html via url

    Hye,

    i'm trying to load xml data into html. Right now i have 3 file (xsl,xml,html) link together in order to transform it. It's working but then how can i transform without the xml file, i mean by passing the url of xml page. Since the xml is from other website and i want the data load into others website. Is there any idea?

    below is my Html file;
    <html>
    <head>
    <link rel="stylesheet" type="text/css" href="style.css"/>
    <script>
    function loadXMLDoc(dname)
    {
    if (window.ActiveXObject)
    {
    xhttp=new ActiveXObject("Msxml2.XMLHTTP.3.0");
    }
    else
    {
    xhttp=new XMLHttpRequest();
    }
    xhttp.open("GET",dname,false);
    xhttp.send("");
    return xhttp.responseXML;
    }

    function displayResult()
    {
    xml=loadXMLDoc("invoke.xml");
    xsl=loadXMLDoc("invoke.xsl");
    // code for IE
    if (window.ActiveXObject)
    {
    ex=xml.transformNode(xsl);
    document.getElementById("example").innerHTML=ex;
    }
    // code for Mozilla, Firefox, Opera, etc.
    else if (document.implementation && document.implementation.createDocument)
    {
    xsltProcessor=new XSLTProcessor();
    xsltProcessor.importStylesheet(xsl);
    resultDocument = xsltProcessor.transformToFragment(xml,document);
    document.getElementById("example").appendChild(resultDocument);
    }
    }





    and xsl file;
    <?xml version="1.0" encoding="ISO-8859-1"?><!-- DWXMLSource="http://wsdl.sotanetwork.com/packages/2_0_2/packageservices.cfc?method=search_travel_packages" -->
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/">

    <html>
    <body>
    <table height="50" border="0">
    <tr><td></td></tr>
    </table>
    <table width="437" border="0" cellpadding="8">
    <xsl:for-each select="PACKAGE_DETAIL/PACKAGE_RESULTS/PACKAGE_RESULT">
    <tr>
    <td width="290" valign="top" bgcolor="#FBF1AE"><p class="style1 style10"><xsl:value-of select="PACKAGE_NAME" /></p>
    <p class="style10"><span class="style4"><xsl:value-of select="TOUR_DURATION" /></span></p>
    <p class="style10"><span class="style4"><xsl:value-of select="TOUR_PERIOD" /></span></p>
    <p class="style10"><span class="style4"><xsl:value-of select="TOUR_DESTINATION" /></span></p>
    <p class="style10"><span class="style4"><xsl:value-of select="TOUR_START" /></span></p>
    <p class="style10"><span class="style4"><xsl:value-of select="PRICE_FROM" /> / <xsl:value-of select="PRICE_FROM_PAX" /></span></p>
    <p class="style10"><span class="style4"><xsl:value-of select="AGENT_NAME" /></span></p>

    <table width="106" height="27" border="0" align="right">
    <tr>
    <td bgcolor="#BA8E61" class="style9"><div align="center" class="style4"><a href="bakoNP.php" class="style9">View Details</a></div></td>
    </tr>
    </table>
    </td>
    </tr>
    </xsl:for-each>
    </table>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>



    Thanks :)

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,038
    Thanks
    23
    Thanked 589 Times in 588 Posts
    I'd like to help you out mashter, but first I need you to do something for me.
    Repost; Your html file is incomplete. Can't tell what the xsl file generates because I do not have the classes style sheet (should be part of the html file(?). and most importantly I need the xml. What you put here is the xsl file.
    When you repost please use the hash mark [the #] located in the toolbar above the message box to generate the [code] tags and place the code inside of them.

    And if you have the url of the xml, that would be nice. If the xsl is also from the external site a link to that would be great also.

    Not sure if I understand the question. Please re-phrase.
    Evolution - The non-random survival of random variants.

  • #3
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you sunfighter, i'm not sure if can post the xml file here since it's not my work but i got a permission to use it. Assume that i use a simple xml, what i need to know is how can i include/attach the xml from website because the data is changed based on user's keyword, so thats why i dont want save the xml file and use it to transform bcoz it will display the same result for whatever keyword user use when search at my index page. Hope u understand what i trying to explain.

  • #4
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,459
    Thanks
    1
    Thanked 23 Times in 21 Posts
    Can you post a minimal testcase XML illustrating what you're trying to do, at least? Fake data that roughly resembles what you're trying to do is better than no data
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #5
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <DETAIL>
    	<COUNT><![CDATA[71]]></COUNT> 
    	<CURRENCY><![CDATA[MYR]]></CURRENCY> 
    	
    	<RESULTS> 
    		<RESULT> 
    			<NAME><![CDATA[ABC Travel]]><NAME> 
    			<CATEGORY><![CDATA[Adventure|Family|Recreational]]></CATEGORY> 
    			<ID><![CDATA[USS3D2N]]></ID> 
    			<NAME><![CDATA[Aquarium Singapore]]></NAME> 
    			<PRICE><![CDATA[66.00]]></PRICE> 
    			<PAX><![CDATA[0 Pax]]></PAX> 
    			<PUBLISH_DATE><![CDATA[]]></PUBLISH_DATE> 
    			<DESTINATION><![CDATA[SINGAPORE]]></DESTINATION> 
    			<DURATION><![CDATA[1D]]></DURATION> 
    			<PERIOD><![CDATA[01/04/2013 - 09/09/2013]]></PERIOD> 
    			<TOUR_START><![CDATA[SINGAPORE, SINGAPORE, SINGAPORE]]></TOUR_START> 
    		</RESULT>
    	</RESULTS>
    </DETAIL>

    as I said..the data will change based on keyword, above is example of result (in xml format) after search a package.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •