Du coup çà me fais çà : (J’ai choisi la solution XmlReader/Writer parce que j’avais commencé par là).
XmlTextReader reader = new XmlTextReader(Server.MapPath(“test.svg”));
XmlTextWriter writer = new XmlTextWriter (Server.MapPath(“test_out.svg”),Encoding.Unicode);
writer.Formatting = Formatting.Indented;
writer.WriteStartDocument(false);
writer.WriteDocType(“svg”, “-//W3C//DTD SVG 20010904//EN”,“http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd”, null);
writer.WriteStartElement(“svg”);
writer.WriteStartElement(“style”);
writer.WriteStartAttribute(null,“type”,null);
writer.WriteString(“text/css”);
writer.WriteCData(“text{font: “+ Request.QueryString[“sizeFont”] +” “+ Request.QueryString[“familyFont”] +”; fill:”+ Request.QueryString[“colorFont”] +";} polygon{stroke:"+ Request.QueryString[“strokeColor”] +";stroke-width:"+ Request.QueryString[“widthStroke”] +" ; stroke-miterlimit:10;}");
if (Request.QueryString[“fillColor”] == “”)
{
if (Request.QueryString[“fillColor1”] != “”)
{
writer.WriteCData(".Fill1{fill:"+ Request.QueryString[“fillColor1”].ToString() +";}");
}
if (Request.QueryString[“fillColor2”] != “”)
{
writer.WriteCData(" .Fill2{fill:"+ Request.QueryString[“fillColor2”].ToString() +";}");
}
if (Request.QueryString[“fillColor3”] != “”)
{
writer.WriteCData(" .Fill3{fill:"+ Request.QueryString[“fillColor3”].ToString() +";}");
}
if (Request.QueryString[“fillColor4”] != “”)
{
writer.WriteCData(" .Fill4{fill:"+ Request.QueryString[“fillColor4”].ToString() +";}");
}
}
else
{
writer.WriteCData(".Fill1{fill:"+ Request.QueryString[“fillColor”].ToString() +";} .Fill2{fill:"+ Request.QueryString[“fillColor”].ToString() +";} .Fill3{fill:"+ Request.QueryString[“fillColor”].ToString() +";} .Fill4{fill:"+ Request.QueryString[“fillColor”].ToString() + “;}”);
}
writer.WriteEndElement();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name.Equals(“g”))
{
if (reader.GetAttribute(“id”) == Request.QueryString[“contenuXML”])
{
writer.WriteNode(reader,true);
}
}
if (reader.Name.Equals("text"))
{
if (reader.GetAttribute("id") == "N-"+Request.QueryString["contenuXML"])
{
writer.WriteStartElement("g");
writer.WriteStartAttribute(null,"id",null);
writer.WriteString("NOM");
writer.WriteNode(reader,true);
writer.WriteEndElement();
}
}
}
}
writer.WriteEndElement();
reader.Close();
writer.Close();
C’est un peu bourrin mais bon…