Torna al Thread
Manifest xmlManifest;
public ManifestDomWriter(Stream outStr)
{
//inizializzo oggetto documento
XmlDocument doc = new XmlDocument();
//inserisco dichirazione e altri parametri
XmlDeclaration decl = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
doc.AppendChild(decl);
string ssText = "type='text/xsl' href='imsmanifest.xsl'";
XmlProcessingInstruction pi = doc.CreateProcessingInstruction("xml-stylesheet",ssText);
doc.AppendChild(pi);
//creo radice
XmlNode root = CreateManifestNode(doc);
doc.AppendChild(root);
//creo oggetto textwriter con codifica
XmlTextWriter writer = new XmlTextWriter(outStr, System.Text.Encoding.UTF8);
//formattazione file xml
writer.Formatting = Formatting.Indented;
//scrive su documento
doc.WriteTo(writer);
writer.Flush();
writer.Close();
}
XmlNode CreateManifestNode(XmlDocument doc)
{
//creo elemento
XmlElement manifest = doc.CreateElement("Manifest");
// MessageBox.Show(xmlManifest.p_xmlns.ToString());
//aggiungo attributi all'elemento
manifest.SetAttribute("xmlns",xmlManifest.p_xmlns.ToString());
//creo nodo figlio
XmlNode orgs = CreateOrgsNode(doc);
manifest.AppendChild(orgs);
//creo nodo figlio
XmlNode ress = CreateRessNode(doc);
manifest.AppendChild(ress);
return manifest;
}