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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP script to convert XML to HTML

    Hi folks,
    I have two questions.

    I'm looking for a PHP script to convet a XML file to a HTML file on the fly. Do you know where I can find this?.

    On the other hand, I create a PDF file using PHP. When the PDF is open on a new web browser, and after a delay of 1 minute, the PDF file must be delete from the server directory. I've try with this PHP instructions:

    sleep(60);
    unlink("$result"); -->where $result has the link to the pdf file.

    but something is worng because I can open the file before delete it (of course). Any ideas.

    Thank

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by aufkes
    I'm looking for a PHP script to convet a XML file to a HTML file on the fly. Do you know where I can find this?.
    There is no script that can convert any XML file to a HTML file, because the script can't figure out for each and every XML file what and how it should convert it. You'll have to build your own routine that transforms the XML file by help of SAX, DOM or XSLT. If you tell us what kind of XML file it is, there may be a premade PHP script to do the conversion. But a general transformer does not exist.
    De gustibus non est disputandum.

  • #3
    New to the CF scene
    Join Date
    Jan 2006
    Location
    India
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    Hi Guys

    I have the following xml generated from flash editor:

    <element>
    <position>
    <X>360</X>
    <Y>1807</Y>
    <width>600</width>
    <height>325</height>
    </position>
    <content><![CDATA[<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="23" COLOR="#000000" LETTERSPACING="0" KERNING="0">Jacob Oram</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="23" COLOR="#000000" LETTERSPACING="0" KERNING="0">Lorem ipsum</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="23" COLOR="#000000" LETTERSPACING="0" KERNING="0">Lorem ipsum</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="23" COLOR="#000000" LETTERSPACING="0" KERNING="0">xyz@example.com</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="23" COLOR="#000000" LETTERSPACING="0" KERNING="0">1800-000-0000 (000)</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="23" COLOR="#000000" LETTERSPACING="0" KERNING="0">1800-800-8000</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="23" COLOR="#000000" LETTERSPACING="0" KERNING="0">www.example.com</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="23" COLOR="#000000" LETTERSPACING="0" KERNING="0">5000 Lorem ipsum</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="23" COLOR="#000000" LETTERSPACING="0" KERNING="0">undefined</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="23" COLOR="#000000" LETTERSPACING="0" KERNING="0">Lorem ipsum</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="23" COLOR="#000000" LETTERSPACING="0" KERNING="0">Lorem ipsum 97035</FONT></P>]]></content>
    <type>text</type>
    </element>
    <element>
    <position>
    <X>126</X>
    <Y>1819</Y>
    <width>200</width>
    <height>300</height>
    </position>
    <content><![CDATA[full-image-path]></content>
    <type>picture</type>
    </element>
    <element>
    <position>
    <X>1446</X>
    <Y>1971</Y>
    <width>150</width>
    <height>150</height>
    </position>
    <content><![CDATA[full-image-path]></content>
    <type>picture</type>
    </element>
    <element>
    <position>
    <X>1361</X>
    <Y>2066</Y>
    <width>50</width>
    <height>57</height>
    </position>
    <content><![CDATA[full-image-path]></content>
    <type>picture</type>
    </element>
    <element>
    <position>
    <X>360</X>
    <Y>838</Y>
    <width>1100</width>
    <height>800</height>
    </position>
    <content><![CDATA[<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="59" COLOR="#000000" LETTERSPACING="0" KERNING="0">Lorem,</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="59" COLOR="#000000" LETTERSPACING="0" KERNING="0"></FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="59" COLOR="#000000" LETTERSPACING="0" KERNING="0">It&apos;s great to see your lips are normal again! I just wanted to say thanks! Now if you could just take care of that wart, everything will be great!</FONT></P>]]></content>
    <type>text</type>
    </element>
    Can you please help me get a html content from the above xml using php?

    Thanks in advance.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,978
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    A little ancient of a thread to dig up.
    There is no methodology to convert direct XML into HTML. That is why there are XSLT's and DOCTypes. Use an XSLT to convert it at the client level, or run the XSL through the XSLTProcessor object to apply it to the DOMDocument of the XML.


  •  

    Posting Permissions

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