Bonjour,

Je voudrai bien insérer mes données du fichier XML vers ma base de donnée.

bouks.xml

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml:stylesheet type="text/xsl" href="books.xsl"?>
<books>
	<book>
    	<title>Dilbert</title>
	    <author>Scott Adams</author>
		<price>13</price>
	</book>
	<book>
    	<title>Le seigneur des anneaux</title>
	    <author>J.R.R Tolkien</author>
		<price>12.50</price>
	</book>
	<book>
    	<title>Harry Potter à l'ecole des sorciers</title>
	    <author>J.K. Rowling</author>
		<price>8.54</price>
	</book>
	<book>
    	<title>les misérables</title>
	    <author>Victor Higo</author>
		<price>7.50</price>
	</book>
</books>
books.xsl

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="books/book">
			<xsl:text> INSERT INTO books (title, author, price) VALUES ( </xsl:text>
			<xsl:value-of select="title"/>
			<xsl:text>, </xsl:text>
			<xsl:value-of select="author"/>
			<xsl:text>, </xsl:text>
			<xsl:value-of select="price"/>
			<xsl:text> </xsl:text>
			<xsl:text>);</xsl:text><br/> 		
	</xsl:template>
</xsl:stylesheet>
execution du books.xml est la suivante :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
INSERT INTO books (title, author, price) VALUES ( Dilbert, Scott Adams, 13 );
INSERT INTO books (title, author, price) VALUES ( Le seigneur des anneaux, J.R.R Tolkien, 12.50 );
INSERT INTO books (title, author, price) VALUES ( Harry Potter à l'ecole des sorciers, J.K. Rowling, 8.54 );
INSERT INTO books (title, author, price) VALUES ( les misérables, Victor Higo, 7.50 );
Mais je voudrais bien inserer mes données dans ma table.
Comment puis-je faire ??