XML, XSL et Date
creanova2000
Messages postés
39
Date d'inscription
jeudi 31 juillet 2003
Statut
Membre
Dernière intervention
21 septembre 2006
-
11 juin 2005 à 00:40
cs_Bidou
Messages postés
5487
Date d'inscription
dimanche 4 août 2002
Statut
Modérateur
Dernière intervention
20 juin 2013
-
11 juin 2005 à 11:13
Bonjour ,
J'essaye de faire une xml transormation en utilisant un fichier xsl
Tout Fonctionne sauf une chose qui n'est pas bien C'est que les date sont de la forme :
2005-03-15T00:00:00.0000000-05:00
Comment je peux me debarrasser de ca je veux que cela soit : 2005-03-15
voici le code de fichier.cs :
try
{
con1.Open();
//Fill a dataset with records from the Customers table.
DataSet objDataset =
new DataSet();
objAdapter.Fill(objDataset);
//Create the FileStream to write with.
System.IO.FileStream fs =
new System.IO.FileStream(@"C:\test.xml", System.IO.FileMode.Create);
//Create an XmlTextWriter for the FileStream.
System.Xml.XmlTextWriter xtw =
new System.Xml.XmlTextWriter(fs, System.Text.Encoding.Default);
//Add processing instructions to the beginning of the XML file, one
//of which indicates a style sheet.
xtw.WriteProcessingInstruction("xml", "version='1.0'");
xtw.WriteProcessingInstruction("xml-stylesheet", "type='text/xsl' href='test.xsl'");
//Write the XML from the dataset to the file.
objDataset.WriteXml(xtw);
objAdapter.Fill(objDataset);
//Create the FileStream to write with.
System.IO.FileStream fs2 =
new System.IO.FileStream(@"C:\test.htm", System.IO.FileMode.Create);
//Create an XmlTextWriter for the FileStream.
System.Xml.XmlTextWriter xtw2 =
new System.Xml.XmlTextWriter(fs2, System.Text.Encoding.Unicode);
//Transform the XML using the stylesheet.
XmlDataDocument xmlDoc =
new XmlDataDocument(objDataset);
System.Xml.Xsl.XslTransform xslTran =
new System.Xml.Xsl.XslTransform();
xslTran.Load(@"C:\test.xsl");
xslTran.Transform(xmlDoc,
null, xtw2);
//Close the database connection.
con1.Close();
}
catch (Exception exp1)
{
}
Merci d'avance
creanova