[program-l] Re: Visual Basic .net: getting XMLWriter not to access the Internet

  • From: "Pranav Lal" <pranav.lal@xxxxxxxxx>
  • To: <program-l@xxxxxxxxxxxxx>
  • Date: Wed, 18 May 2011 20:41:56 +0530

Hi Ian,

I did and no go. Any how, I have solved the problem by using the xDocument
class. I was fooling around with all sorts of combinations of xDocument,
xmlTextWriter and xmlTextReader. The final code that solved this problem is
as follows
Dim xxd As XDocument = XDocument.Parse(svs)

        xxd.Save(tempFile)

There are more issues with the file now since I broke something along the
way but those are subjects for a separate post.

Thanks for all your help.
Pranav        

-----Original Message-----
From: program-l-bounce@xxxxxxxxxxxxx [mailto:program-l-bounce@xxxxxxxxxxxxx]
On Behalf Of Ian Sharpe
Sent: Wednesday, May 18, 2011 7:15 PM
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: Visual Basic .net: getting XMLWriter not to access
the Internet

OK, I think this is a unix/windows file line endings issue. I suspect the
original XML file uses unix line ending characters which the XmlTextReader
doesn't like. Replace the CR characters with CR+LF and try that.

Cheers
ian  

-----Original Message-----
From: program-l-bounce@xxxxxxxxxxxxx [mailto:program-l-bounce@xxxxxxxxxxxxx]
On Behalf Of Pranav Lal
Sent: 18 May 2011 14:21
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: Visual Basic .net: getting XMLWriter not to access
the Internet

Hi Ian,

I have the following code.
        Dim XMLWR As XmlTextWriter = New XmlTextWriter(tempFile, Nothing)
XMLWR.Formatting = Formatting.Indented Dim xmlr As XmlTextReader

        Dim xss As New XmlReaderSettings

        xmlr = New XmlTextReader(ms)
        xmlr.WhitespaceHandling = WhitespaceHandling.None

        xss.IgnoreProcessingInstructions = True
        xss.ValidationType = ValidationType.None
        Dim reader As XmlReader = XmlReader.Create(xmlr, xss)

        'convert the xml string to a file and read it back into an array
list
        'This also ensures that the string is read correctly into the
arrayList.
        'each element in the list corresponds to one line in the file.
        Try
            While reader.Read
                XMLWR.WriteNode(reader, False)
            End While
        Catch xx As Exception

            MsgBox(xx.Message)
            quit()
        End Try
        Try
            xmlr.Close()

            XMLWR.Flush()
            XMLWR.Close()
        Catch lx As Exception
            MsgBox("Error in writing temporary xml. Quitting")
            My.Application.Log.WriteException(lx)
            quit()
        End Try
        XMLWR = Nothing
        xmlr = Nothing

I get the following error when this code runs.
The server committed a
protocol violation. Section=ResponseHeader Detail=CR must be followed by LF
OK         

Pranav

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

Other related posts: