Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

[OT] Re: Converting very nested XHTML to XML

by idsfa (Vicar)
on Jul 07, 2006 at 21:37 UTC ( #559869=note: print w/ replies, xml ) Need Help??


in reply to Converting very nested XHTML to XML

Not knowing what your original XHTML looks like, I can only provide a general XSLT. In the following, I assume each row in a table either contains a table or a td which is the name (your tags may vary). This allows xsl:apply-templates to recursively call the table template.

<xsl:template match="table"> <node> <xsl:for-each select="tr"> <xsl:apply-templates /> </xsl:for-each> </node> </xsl:template> <xsl:template match="td"> <name><xsl:value-of select="." /></name> </xsl:template>

Here's a more complete example.


The intelligent reader will judge for himself. Without examining the facts fully and fairly, there is no way of knowing whether vox populi is really vox dei, or merely vox asinorum. — Cyrus H. Gordon


Comment on [OT] Re: Converting very nested XHTML to XML
Select or Download Code
Re: [OT] Re: Converting very nested XHTML to XML
by richill (Monk) on Jul 10, 2006 at 16:05 UTC
    The actual html is here, the trouble Im having is that the relationships between the <node> and the following <node> is indicated by the number of images preceeding the TD containing the node name. I guess I need to learn more xslt better because I dont know how to write a rule for that at the moment..

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://559869]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2014-12-18 09:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (48 votes), past polls