Hello All,
I am using the XMLTextWriter to create a XML file for a client. The data is coming from the database for the file. I have couple of issues that I need to resolve, but not sure how to do that.
1. If the field has no data the XMLTextWriter will write the element as
<Name /> instead of <Name> </Name>. I know they both mean
the same, but the client requires it in the form <Name> </Name>
format.
2. When the XML file is generated, the very first line is written as
<?xml version="1.0"?>, I would like the encoding in there as well. For
Example the line should read <?xml version="1.0" encoding="utf-8" ?>.
Here is the start of the code.......
Any help would be appreciated. Thanks in advance.
I am using the XMLTextWriter to create a XML file for a client. The data is coming from the database for the file. I have couple of issues that I need to resolve, but not sure how to do that.
1. If the field has no data the XMLTextWriter will write the element as
<Name /> instead of <Name> </Name>. I know they both mean
the same, but the client requires it in the form <Name> </Name>
format.
2. When the XML file is generated, the very first line is written as
<?xml version="1.0"?>, I would like the encoding in there as well. For
Example the line should read <?xml version="1.0" encoding="utf-8" ?>.
Here is the start of the code.......
VB.NET:
xmlWriter = New XmlTextWriter(xmlFile, Nothing)
'set the formatiing for the xml file
xmlWriter.Formatting = Formatting.Indented
xmlWriter.Indentation = 4
xmlWriter.IndentChar = " "c
xmlWriter.WriteStartDocument()
'Write the Root Node
xmlWriter.WriteStartElement("File")
'write the attribute for the file element
xmlWriter.WriteAttributeString("xmlns",".....")
'Write First Node
xmlWriter.WriteStartElement("Filer_Information")
'Write the attribute for the file_Information
xmlWriter.WriteAttributeString("xmlns", ".......")
xmlWriter.WriteElementString("Date", Format(Now, "yyyyMMddhhmmss"))
xmlWriter.WriteEndElement()
'Write Reports Node
xmlWriter.WriteStartElement("Reports")
'
'
'
Last edited by a moderator: