Re: Illegal Charaters in path



Hi Claes,

I am getting this file from web. I am downloading this file using
webclient and how how it is adding 1 character before the actual file.
Stripping the first character solved the problem though. But why and
what is this first character?

Thanks.

Claes Bergefall wrote:
"DBC User" <dbcuser@xxxxxxxxx> wrote in message
news:1156884340.080076.56420@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

I have a small XML file, I uploaded to a web page. I have the following
code to convert the content I downloaded from web to xml and is giving
"Illegal characters in path", but when I try to see the value in XML
viewer (through add watch) and is showing the content correctly.

Here is the code
..
string b = wc.DownloadString(myurl);
XmlDocument doc = new XmlDocument();
doc.Load(str);
....

Could someone tell me what is wrong?

XmlDocument.Load doesn't have an overlaod that loads XML from a string. The
string overload expects a filename. Put your string in a StringReader and
then load from that:

XmlDocument doc = new XmlDocument();
StringReader reader = new StringReader(b);
doc.Load(reader);


When I change the Load to LoadXml I get 'Data at the root level is
invalid. Line 1, position 1"

Here is the XML
<?xml version="1.0" encoding="utf-8" ?>
<Files>
<Application key="one">
<Version>1.0</Version>
</Application>
</Files>


LoadXml works with the above XML. Not sure why you get an error

/claes

.



Relevant Pages

  • Re: Non-ascii characters in VS.NET service
    ... method that takes a string parameter. ... How is it turning the character into hex? ... What do you mean by "an XML header"? ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: System.ArgumentException: Illegal characters in path
    ... But I don't use any xml string at all in my web ... It is a default data type string and I wonder it ... cannot accept latin character since string accepts all utf-8 characters. ... Microsoft XML 3.0 SP1 ...
    (microsoft.public.dotnet.framework.webservices)
  • RE: Xml deserialization problem..help needed.
    ... "The '*' character, hexadecimal value 0x2A, cannot begin with a name. ... set of characters...in the value of an xml element. ... I am deserializing the xml data into a c# class I have created. ... All I want to do is take a string of xmldata and deserialize it into a class. ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: How to parse XML which contains & in the text ?
    ... "The ampersand character and the left angle bracket MUST NOT appear in their literal form, except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. ... bracket may be represented using the string ">", and MUST, for compatibility, be escaped using either ">" or a character reference when it appears in the string "]]>" in content, when that string is not marking the end of a CDATA section." ... You can't fix this in the DTD, the XML is invalid and the parser is correct to reject it. ...
    (comp.lang.java.programmer)
  • [TOMOYO #15 3/8] Common functions for TOMOYO Linux.
    ... This file contains common functions (e.g. policy I/O, pattern matching). ... Since TOMOYO Linux is a name based access control, ... TOMOYO Linux's string manipulation functions make reviewers feel crazy, ... the Linux kernel accepts all characters but NUL character ...
    (Linux-Kernel)