1

Here is my xml:

<Catalog>
    <catalogDetail catalogId="DemoCatalog">
        <catalogName>Demo Catalog</catalogName>
    </catalogDetail>
    <catalogDetail catalogId="GoogleCatalog">
        <catalogName>Google Catalog</catalogName>
    </catalogDetail>
</Catalog>

I want it to be read in HTML file how can I do this???

dfsq
  • 191,768
  • 25
  • 236
  • 258
Sandy
  • 39
  • 1
  • 1
  • 4

3 Answers3

2

To do this your HTML file should contain some JavaScript code, so you will want to learn how to parse XML in Javascript.

Here is a good StackOverflow question on this topic: XML parsing in JavaScript

Community
  • 1
  • 1
Luc125
  • 5,752
  • 34
  • 35
1

You can do by using PHP's XML Library called simplexml for more information check this link http://www.w3schools.com/php/php_xml_simplexml.asp

johndavedecano
  • 522
  • 5
  • 11
1

NOTE : If you can elaborate on what technology you're using, I'll try to provide a more complete example.

I would suggest using XSLT for this. With XSLT, you can pass in the XML fragment, parse it, and return formatted HTML.

Here's an example XSLT document that converts XML to HTML:

<?xml version="1.0" encoding="utf-8"?>  
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">  
    <xsl:output method="html" indent="yes"/>       
    <xsl:template match="/">  
      <html>  
        <body>  
          <h2>My CD Collection</h2>  
          <table border="1">  
            <tr bgcolor="#9acd32">  
              <th>Title</th>  
              <th>Artist</th>  
            </tr>  
            <xsl:for-each select="catalog/cd">  
              <tr>  
                <td>  
                  <xsl:value-of select="title"/>  
                </td>  
                <td>  
                  <xsl:value-of select="artist"/>  
                </td>  
              </tr>  
            </xsl:for-each>  
          </table>  
        </body>  
      </html> 
    </xsl:template>   
</xsl:stylesheet>
James Johnson
  • 45,496
  • 8
  • 73
  • 110