Results 1 to 5 of 5

Thread: Xml Open and Closing

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2007
    Posts
    307

    Xml Open and Closing

    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

    Code:
       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)
    Thats not all of it.. but what happens is if it is blank value

    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

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Xml Open and Closing

    Hey,

    Code:
    <Fuel />
    Is perfectly valid XML. It would suggest to me, that:

    Code:
    myreader("rvfuel").ToString
    Is returning an empty string. Can you step into your code with the debugger to validate that this is what is happening?

    Gary

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2007
    Posts
    307

    Re: Xml Open and Closing

    Yeah i am pretty sure its returning empty string without looking.
    Thats what i saw in database.

    Maybe there feed doesnt like it or they dont know better

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Xml Open and Closing

    Sounds like they are probably manually parsing the XML, (as opposed to using an XML parser of some kind) which quite frankly surprises and disappoints me. I'd talk to them, explain that what you are producing is not only valid XML, but universally accepted and try to find out why they won't accept it on their end.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Xml Open and Closing

    Quote Originally Posted by techgnome View Post
    Sounds like they are probably manually parsing the XML, (as opposed to using an XML parser of some kind) which quite frankly surprises and disappoints me. I'd talk to them, explain that what you are producing is not only valid XML, but universally accepted and try to find out why they won't accept it on their end.

    -tg
    Couldn't agree more!!

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width