xml to html tables based on id
Sorry i've a newbie question. I am trying to prepare some xml data for insertion into a MySQL database. I have about 70k records in this general form:
<fut>
<PartNumber>123010335</PartNumber>
<Make>Hiderel</Make>
<Model>SuperG</Model>
<Country>开发者_C百科USA</Country>
<DateFrom>1970-08</DateFrom>
<DateTo>1980-01</DateTo>
</fut>
<fut>
<PartNumber>123010335</PartNumber>
<Make>Hiderel</Make>
<Model>Minim</Model>
<Country>USA</Country>
<DateFrom>1960-08</DateFrom>
<DateTo>1974-07</DateTo>
</fut>
<fut>
...
</fut>
What I'd like to ultimately do is create an individual html tables for each partnumber and have the table rows contain cells with make, model, country,datefrom, dateto.
Any recommendations on what is the best way to go about this? Xquery or SQL or any other alternatives?
Your sample does not seem to be XML, more like tab separated values. I recommend entering it into a MySQL table as you can find more information on SQL than on FLOVR (the sql-like query language for XML documents).
The following XSLT will create SQL INSERT statements from your XML:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="fut">
INSERT INTO mytable (PartNumber, Make)
VALUES ('<xsl:value-of select="PartNumber"/>', '<xsl:value-of select="Make"/>');
</xsl:template>
</xsl:stylesheet>
精彩评论