How limitate the attribute of the root to it?
-
Hi, I have this code to generate xml file;
XmlTextWriter myXmlTextWriter = new XmlTextWriter ("D:/New Folder/MyXmlff.xml",System.Text.Encoding.UTF8);
myXmlTextWriter.Formatting = Formatting.Indented;
myXmlTextWriter.WriteStartDocument(false);
myXmlTextWriter.WriteStartElement("root");
myXmlTextWriter.WriteAttributeString("xmlns","urn:iso:std:iso:20022:tech:xsd:pain.001.001.02");
myXmlTextWriter.WriteStartElement("pain.001.001.02");
myXmlTextWriter.WriteComment("Section A : Group Header");
myXmlTextWriter.WriteStartElement("GrpHdr");
myXmlTextWriter.WriteStartElement("MsgId");
myXmlTextWriter.Flush();
myXmlTextWriter.WriteEndElement();
myXmlTextWriter.WriteEndElement();
myXmlTextWriter.Close();the problem is the attribute of the root appears always in other tags like this: </Salarié> </pain.001.001.02> </root> but i want that xmlns appears ONLY as an attribute of the root like this: FVIR/101230/1 2010-12-30T17:02:21 thank u for u help hugs false
-
Hi, I have this code to generate xml file;
XmlTextWriter myXmlTextWriter = new XmlTextWriter ("D:/New Folder/MyXmlff.xml",System.Text.Encoding.UTF8);
myXmlTextWriter.Formatting = Formatting.Indented;
myXmlTextWriter.WriteStartDocument(false);
myXmlTextWriter.WriteStartElement("root");
myXmlTextWriter.WriteAttributeString("xmlns","urn:iso:std:iso:20022:tech:xsd:pain.001.001.02");
myXmlTextWriter.WriteStartElement("pain.001.001.02");
myXmlTextWriter.WriteComment("Section A : Group Header");
myXmlTextWriter.WriteStartElement("GrpHdr");
myXmlTextWriter.WriteStartElement("MsgId");
myXmlTextWriter.Flush();
myXmlTextWriter.WriteEndElement();
myXmlTextWriter.WriteEndElement();
myXmlTextWriter.Close();the problem is the attribute of the root appears always in other tags like this: </Salarié> </pain.001.001.02> </root> but i want that xmlns appears ONLY as an attribute of the root like this: FVIR/101230/1 2010-12-30T17:02:21 thank u for u help hugs false
I assume this is a small fragment of your code, not the entire body of the method. Does the number of calls to WriteEndElement in your program match the number of calls to WriteStartElement?