I am using the xmltextwriter and having issues with opening tags not showing if the field is blank
here is the start of my code
Thats not all of it.. but what happens is if it is blank valueCode:Dim strFilePath As String = Server.MapPath("../test.xml") Dim utf8 As Encoding = New UTF8Encoding(False) Dim objWriter As XmlTextWriter = New XmlTextWriter(strFilePath, New UTF8Encoding(False)) ' start writing the XML document objWriter.WriteStartDocument() Try conn.Open() myreader = cmd.ExecuteReader objWriter.WriteStartElement("testfile") While myreader.Read ' output the first "product" element objWriter.WriteStartElement("product", Nothing) objWriter.WriteElementString("Id", myreader("rvid").ToString) objWriter.WriteElementString("Class", myreader("RVClass").ToString) objWriter.WriteElementString("Manu", myreader("rvmanu").ToString) objWriter.WriteElementString("Model", myreader("rvmake") & " " & myreader("rvmodel")) objWriter.WriteElementString("Year", myreader("rvyear").ToString) objWriter.WriteElementString("Price", myreader("rvcashprice").ToString) objWriter.WriteElementString("NU", myreader("rvnu").ToString) objWriter.WriteElementString("SCapacity", myreader("rvcapacity").ToString) objWriter.WriteElementString("Fuel", myreader("rvfuel").ToString) objWriter.WriteElementString("Length", myreader("rvlenft").ToString) objWriter.WriteElementString("Air", myreader("rvair").ToString) objWriter.WriteElementString("Awnings", myreader("rvawnings").ToString)
Then i get this, as you see fuel has no opening tags, and the company i am supplying to needs these.
<Price>0.0000</Price>
<NU>U</NU>
<SCapacity>0</SCapacity>
<Fuel />
<Length>0</Length>
What can i do to make this work how i want? I though the .tostring woudl fix it but it didnt.
Thanks




Reply With Quote