I'm trying to write a transform to parse an html document and create another html document but I can't seem to use the html tags in the xslt.

My html source that I want to apply the transform on looks like this:

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
    </head>
    <body class="3-column">
        <div class="centercol"><p>Hello world</p></div>
         <div class="leftcol">
                    <div id="menu">

                    </div>
          </div>
         <div class="rightcol"> </div>
    </body>
</html>

My XSLT looks like this:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
    <xsl:template match="/*">
        <xsl:value-of select="body/div/p"/>
    </xsl:template>
</xsl:stylesheet>

Can anyone help me figure out how to get my xpaths to work with html tags?

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:x="http://www.w3.org/1999/xhtml" version="1.0">
  <xsl:template match="/*">
    <xsl:value-of select="x:body/x:div/x:p"/> //note changes to this line
  </xsl:template>
</xsl:stylesheet>

I've assigned the HTML namespace to x, so now we prefix all references to the XML with x: and then you can find the nodes you were missing before :)

Proof in action:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:x="http://www.w3.org/1999/xhtml" version="1.0">
  <xsl:template match="/*">
    <xsl:value-of select="x:body/x:div/x:p"/>
  </xsl:template>
</xsl:stylesheet>

run on

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title></title>
  </head>
  <body class="3-column">
    <div class="centercol">
      <p>Hello world</p>
    </div>
    <div class="leftcol">
      <div id="menu">
      </div>
    </div>
    <div class="rightcol"> </div>
  </body>
</html>

gives:

<?xml version="1.0" encoding="utf-8"?>Hello world
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.