When I urlEncode a string (namely a xml file) in some ocassions it adds %00 character at the end of the file. I'd like to know why it happens this and if it can be prevented (i can always erase the %00 characters). The xml file was created using xmlwriter. Weird thing is I use the same code to create other xml files and after encoding them it doesn't add %00 characters.
Example:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE peticion >
<peticion>
    <nombre>Info hotel</nombre>
    <agencia>HOTUSA</agencia>
    <tipo>15</tipo>
</peticion>
Edit: to create the xml this is what I do.
Dim xmlWriterSettings As New System.Xml.XmlWriterSettings
        With xmlWriterSettings
            .Encoding = Encoding.GetEncoding("iso-8859-1")
            .OmitXmlDeclaration = False
            .Indent = True
        End With
        Dim ms As New IO.MemoryStream
        Using writer As System.Xml.XmlWriter = System.Xml.XmlWriter.Create(ms, xmlWriterSettings)
            With writer
                .WriteDocType("peticion", Nothing, Nothing, Nothing)
                .WriteStartElement("peticion")
                .WriteElementString("nombre", "Info hotel")
                .WriteElementString("agencia", "HOTUSA")
                .WriteElementString("tipo", "15")
                .WriteEndElement()
            End With
        End Using
        Dim xml As String = Encoding.GetEncoding("iso-8859-1").GetString(ms.GetBuffer)
Dim XmlEncoded As String = HttpUtility.UrlEncode(xml)
XmlEncoded contains:
%3c%3fxml+version%3d%221.0%22+encoding%3d%22iso-8859-1%22%3f%3e%0d%0a%3c!DOCTYPE+peticion+%3e%0d%
0a%3cpeticion%3e%0d%0a++%3cnombre%3eInfo+hotel%3c%2fnombre%3e%0d%0a++%3cagencia%3eHOTUSA%3c%
2fagencia%3e%0d%0a++%3ctipo%3e15%3c%2ftipo%3e%0d%0a%3c%2fpeticion%3e%00%00%00%00%00%00%00%00%00%
00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%
00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%
00%00%00%00%00%00%00%00%00%00%00%00%00%00
Where all these %00 come from?
 
     
     
    