I want to create a xml file using C# and I have some problem ,my method thus ;
xmlDocument.WriteStartElement("SALES_INVOICES");
xmldocument.WriteEndElement();
the Result is SALES_INVOICES>
SALES_INVOICES>
I Want to result is for WriteStartElement SALES_INVOICES> and WriteEndElement for INVOICES>
Thanks in advance .

VulpesRank #55 · 29.2K reputationPosted May 16, 2014, 6:02 AM EDT
When I ran that code just now I obtained:
which is what I expected.
Can you clarify what you it is you're getting and what you want it to be.
Demir Acar94 reputationPosted May 16, 2014, 6:14 AM EDT
And Result is
I want to modify last endelement TAG
SO ; WriteStartElement is
and Wanna be Last writeendelement is
VulpesRank #55 · 29.2K reputationPosted May 16, 2014, 6:49 AM EDT
then the output should now be:
Demir Acar94 reputationPosted May 16, 2014, 7:05 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 16, 2014, 7:51 AM EDT
The tags must match otherwise the XML document would be malformed.
Demir Acar94 reputationPosted May 16, 2014, 7:57 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 16, 2014, 8:13 AM EDT
However, if you try to load this file into an XmlDocument:
you'll get the following exception:
Unhandled Exception: System.Xml.XmlException: The 'SALES_INVOICES' start tag on
line 2 position 2 does not match the end tag of 'INVOICES'. Line 4, position 3.
at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
at System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag)
at System.Xml.XmlTextReaderImpl.ParseEndElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.Load(String filename)