Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML/XSL help

Status
Not open for further replies.
Oct 17, 2011
1
US
Hi guys, i'm really new at xml and xsl. all im tyring to do is grab information from the xml then use an xsl file to perform a sql insert. I'm trying to get all <a> values from the different <id>'s.

Please help:

Here's the xml im using:

<?xml version="1.0" encoding="utf-8" ?>
- <survey xmlns="xmlns:xsi="xmlns:xsd="xmlns:survey="
- <questionnaire>
- <q>
<id>0</id>
</q>
- <q>
<id>1</id>
<a>40</a>
</q>
- <q>
<id>2</id>
<a>Iwork</a>
</q>
</questionnaire>
</survey>

And here's the xsl im working on:
<xsl:stylesheet version="1.0"
xmlns:xsl=" xmlns:s="
<xsl:eek:utput method="xml"/>

<xsl:template match="/ns:survey">
<xsl:element name="SQL">
<xsl:apply-templates select="ns:questionnaire/ns:q"/>
</xsl:element>
</xsl:template>

<xsl:template match="ns:q/[child::ns:id=1]">
<xsl:element name="Command">
<xsl:attribute name="nonQuery">
<xsl:text>false</xsl:text>
</xsl:attribute>
<xsl:attribute name="type">
<xsl:text>text</xsl:text>
</xsl:attribute>


<xsl:text>INSERT INTO Staff (StaffID) VALUES ('</xsl:text>
<xsl:value-of select="ns:a"/>
<xsl:text>')</xsl:text>



</xsl:element>
</xsl:template>

</xsl:stylesheet>

Thank you in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top