The info is exactly as provided, but let's put it all together. My input
file, that is being loaded looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<ContentBoxes>
<Container id="Literal1">
<add href="There.aspx" />
<add href="That.aspx" />
<add href="There1.aspx" />
<add href="That1.aspx" />
<add href="That1.aspx" />
<add href="JumpTo.aspx?r=0&t=m" /> <========= Offending
Line
</Container>
</ContentBoxes>
As shown from my original file, the 6th "add" child element is the offending
one, but then ONLY when I add
the &t=m if I leave it out "JumpTo.aspx?r=0" then no error is produced.
As for what is at line X position Y, it doesn't matter because every time I
get that error, the line & Position the
Xml reports to me does not match with the actual file. BUT I know THAT is
the offending line.
Test Case #1: JumpTo.aspx?r=0&t=m ---> the error shown in the follow
up post from me
Test Case #2: JumpTo.aspx?r=0 ---> everything works fine, no
error is produced
Then I suppose the next question is "but HOW do you read this file?", ok,
here is the relevant code snippets:
StreamReader sr = new StreamReader(this.MapPath(filename));
XmlDocument doc = new XmlDocument();
doc.Load(sr); // <=======
Exception occurrs here ONLY with Test Case #1
string xpath = string.Format("descendant::Container[@id='{0}']",
containerID);
XmlNode node = doc.DocumentElement.SelectSingleNode(xpath);
:
sr.Close();
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:eG**************@TK2MSFTNGP15.phx.gbl...
~~~ .NET Ed ~~~ wrote:
I have a standalone XML file (with the appropriate xml document
header) that works fine when I load it using XmlDocument. I can have
child elements like this without problems:
<SomeChildElement type="c" href="There.aspx?id=5" />
But as soon as I change it to something like this:
<SomeChildElement type="c" href="There.aspx?id=5&t=m" />
I get an XML Exception indicating that it expected quote (or something
like that). I thought the & was an internatl entity that could always
be used. Or can it only be used as part of an InnerText but not an
Attribute?
How can I resolve that problem?
That's weird. I can't reproduce the problem. What is at Line 14, position
32 ? Provide more info anyway.
--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com