[Aps net 1.1]There are multiple root elements
Bonjour,
je bosse avec c# 1.1 webform et
j'essayes en vain d'applique une transformation xslt sur un fichier xml issue d'un dataset afin d'obtenir un fichier html.!
lors de l'execution du code j'obtiens ce message d'erreur :
There are multiple root elements. Line 4, position 2.
J'ai beau cherche je trouve pas ce qui se passe si quelqu'un avait une idée, voici mon code et un bout de mes fichiers xml xslt.
Le fichier xml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
<?xml version="1.0" encoding="UTF-8" ?>
<NewDataSet>
<TableMachine>
<ComputerName>VORTIGON6-1</ComputerName>
<OperatingSystem>WIN 2003 SP1 english</OperatingSystem>
<User>administrator</User>
<Pwd>.pwroot</Pwd>
</TableMachine>
<TableMachine>
<ComputerName>VORTIGON6-4</ComputerName>
<OperatingSystem>WN 2003 SR2 English</OperatingSystem>
<User>administrator</User>
<Pwd>.pwroot</Pwd>
</TableMachine>
<TableMachine>
<ComputerName>VORTIGON6-5</ComputerName>
<OperatingSystem>WIN 2003 SR2 Deutch</OperatingSystem>
<User>administrator</User>
<Pwd>.pwroot</Pwd>
</TableMachine>
<</NewDataSet> |
le fichier xslt :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
<?
xmlversion="1.0"encoding="UTF-8"?>
<
stylesheetversion="1.0"xmlns="http://www.w3.org/1999/XSL/Transform">
</
stylesheet>
<
xsl:templatematch="/">
<tableborder="1"align="center">
<tr>
<thbgcolor="grey">Computer Name</th>
<thbgcolor="grey">OS</th>
<thbgcolor="grey">User</th>
<thbgcolor="grey">Pwd</th>
</tr>
<xsl:for-eachselect="NewDataSet/TableMachine">
<tr>
<td>
<xsl:value-ofselect="ComputerName"/>
</td>
<td>
<xsl:value-ofselect="OperatingSystem"/>
</td>
<td>
<xsl:valueofselect="User"/>
</td>
<td>
<xsl:valueofselect="Pwd"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</
xsl:stylesheet> |
et le bout de code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
string
xmlSource = "xmlMachineTest.xml";
string xslSource = "XSLTMachine.xsl";
string output = Server.MapPath("RESULT_XSLT.html");
XmlUrlResolver resolver =
new XmlUrlResolver( );
resolver.Credentials = System.Net.CredentialCache.DefaultCredentials;
XslTransform xsltrans=
new XslTransform();
xsltrans.Load(Server.MapPath(xslSource),resolver);
xsltrans.Transform(Server.MapPath(xmlSource),output,resolver); |
Je vous remercie
Christophe