Reading XML File, '<br>' gives 'Element' is not a valid node type
I'm returning a string from an xml file and trying to do something
like the following.
<Getter>
return HtmlEncode(s_tring.Value.Replace("\n","<br>"));
</Getter>
to replace a new-line character with a html line break.
But the "<BR>" is giving me errors as indicated in the title.
presumable it is parsing the string and thinking <br> is the start of
a new field in the xml file.
How can I go about reformatting it to let it through?
<?xml version="1.0" encoding="utf-8" ?> - if that effects things at
all. xml isnt my expertise :)
Re: Reading XML File, '<br>' gives 'Element' is not a valid node type
Not really sure what you're doing, but in xml "<br>" is not valid, try this
instead;
return HtmlEncode(s_tring.Value.Replace("\n","<br/>"));
Note the forward slash after the br but before the closing bracket.
"JB" <jamesb457 [at] gmail.com> wrote in message
news:a6039f9e-2435-4bdd-a3cf-8d91a24afe2a [at] 1g2000prg.googlegr oups.com...
> I'm returning a string from an xml file and trying to do something
> like the following.
>
> <Getter>
> return HtmlEncode(s_tring.Value.Replace("\n","<br>"));
> </Getter>
>
> to replace a new-line character with a html line break.
> But the "<BR>" is giving me errors as indicated in the title.
>
> presumable it is parsing the string and thinking <br> is the start of
> a new field in the xml file.
>
> How can I go about reformatting it to let it through?
>
>
>
> <?xml version="1.0" encoding="utf-8" ?> - if that effects things at
> all. xml isnt my expertise :)
>
Re: Reading XML File, '<br>' gives 'Element' is not a valid node type
"JB" <jamesb457 [at] gmail.com> wrote in message
news:a6039f9e-2435-4bdd-a3cf-8d91a24afe2a [at] 1g2000prg.googlegr oups.com...
> I'm returning a string from an xml file and trying to do something
> like the following.
>
> <Getter>
> return HtmlEncode(s_tring.Value.Replace("\n","<br>"));
> </Getter>
>
> to replace a new-line character with a html line break.
> But the "<BR>" is giving me errors as indicated in the title.
>
> presumable it is parsing the string and thinking <br> is the start of
> a new field in the xml file.
>
> How can I go about reformatting it to let it through?
>
>
>
> <?xml version="1.0" encoding="utf-8" ?> - if that effects things at
> all. xml isnt my expertise :)
You might try
<Getter><![CDATA[return
HtmlEncode(s_tring.Value.Replace("\n","<br>"));]]></Getter>
vmike
Re: Reading XML File, '<br>' gives 'Element' is not a valid node type
On 8 Apr, 16:09, "vMike" <vM... [at] 5noerrawgespam.com> wrote:
> "JB" <jamesb... [at] gmail.com> wrote in message
>
> news:a6039f9e-2435-4bdd-a3cf-8d91a24afe2a [at] 1g2000prg.googlegr oups.com...
>
>
>
> > I'm returning a string from an xml file and trying to do something
> > like the following.
>
> > <Getter>
> > =A0 =A0return HtmlEncode(s_tring.Value.Replace("\n","<br>"));
> > </Getter>
>
> > to replace a new-line character with a html line break.
> > But the "<BR>" is giving me errors as indicated in the title.
>
> > presumable it is parsing the string and thinking <br> is the start of
> > a new field in the xml file.
>
> > How can I go about reformatting it to let it through?
>
> > <?xml version=3D"1.0" encoding=3D"utf-8" ?> - if that effects things at
> > all. xml isnt my expertise :)
>
> You might try
> <Getter><![CDATA[return
> HtmlEncode(s_tring.Value.Replace("\n","<br>"));]]></Getter>
>
> vmike
I tried "<br/>" and that gives me the same error as before.
using <![CDATA[ ....]]
gives me 'This is an unexpected token. The expected token is '['. Line
1006, position 18. '
The stack trace is next to useless, just says there is a problem
reading the xml.
It works spot on if dont have the <br> in there, for example I replace
'\n' with '^' and its all good, but that doesnt help me format the
string :)
Re: Reading XML File, '<br>' gives 'Element' is not a valid node type
"JB" <jamesb457 [at] gmail.com> wrote in message
news:d0b8d242-254d-4e1d-9e55-db50f5bf6b91 [at] u12g2000prd.google groups.com...
On 8 Apr, 16:09, "vMike" <vM... [at] 5noerrawgespam.com> wrote:
> "JB" <jamesb... [at] gmail.com> wrote in message
>
> news:a6039f9e-2435-4bdd-a3cf-8d91a24afe2a [at] 1g2000prg.googlegr oups.com...
>
>
>
> > I'm returning a string from an xml file and trying to do something
> > like the following.
>
> > <Getter>
> > return HtmlEncode(s_tring.Value.Replace("\n","<br>"));
> > </Getter>
>
> > to replace a new-line character with a html line break.
> > But the "<BR>" is giving me errors as indicated in the title.
>
> > presumable it is parsing the string and thinking <br> is the start of
> > a new field in the xml file.
>
> > How can I go about reformatting it to let it through?
>
> > <?xml version="1.0" encoding="utf-8" ?> - if that effects things at
> > all. xml isnt my expertise :)
>
> You might try
> <Getter><![CDATA[return
> HtmlEncode(s_tring.Value.Replace("\n","<br>"));]]></Getter>
>
> vmike
I tried "<br/>" and that gives me the same error as before.
using <![CDATA[ ....]]
gives me 'This is an unexpected token. The expected token is '['. Line
1006, position 18. '
The stack trace is next to useless, just says there is a problem
reading the xml.
It works spot on if dont have the <br> in there, for example I replace
'\n' with '^' and its all good, but that doesnt help me format the
string :)
Make sure you have the closing > for the the cdata function. I can
successfully open the xml file without error with a <br> in it using
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Getter><![CDATA[return
HtmlEncode(s_tring.Value.Replace("\n","<br>"));]]></Getter>
Mike
Re: Reading XML File, '<br>' gives 'Element' is not a valid node type
Tried using
<br/>
instead of <br/>?
"JB" <jamesb457 [at] gmail.com> wrote in message
news:d0b8d242-254d-4e1d-9e55-db50f5bf6b91 [at] u12g2000prd.google groups.com...
On 8 Apr, 16:09, "vMike" <vM... [at] 5noerrawgespam.com> wrote:
> "JB" <jamesb... [at] gmail.com> wrote in message
>
> news:a6039f9e-2435-4bdd-a3cf-8d91a24afe2a [at] 1g2000prg.googlegr oups.com...
>
>
>
> > I'm returning a string from an xml file and trying to do something
> > like the following.
>
> > <Getter>
> > return HtmlEncode(s_tring.Value.Replace("\n","<br>"));
> > </Getter>
>
> > to replace a new-line character with a html line break.
> > But the "<BR>" is giving me errors as indicated in the title.
>
> > presumable it is parsing the string and thinking <br> is the start of
> > a new field in the xml file.
>
> > How can I go about reformatting it to let it through?
>
> > <?xml version="1.0" encoding="utf-8" ?> - if that effects things at
> > all. xml isnt my expertise :)
>
> You might try
> <Getter><![CDATA[return
> HtmlEncode(s_tring.Value.Replace("\n","<br>"));]]></Getter>
>
> vmike
I tried "<br/>" and that gives me the same error as before.
using <![CDATA[ ....]]
gives me 'This is an unexpected token. The expected token is '['. Line
1006, position 18. '
The stack trace is next to useless, just says there is a problem
reading the xml.
It works spot on if dont have the <br> in there, for example I replace
'\n' with '^' and its all good, but that doesnt help me format the
string :)
Re: Reading XML File, '<br>' gives 'Element' is not a valid node type
Try :
Notice the space between the "r" and the slash.
i.e., <br/> is wrong, but
is OK.
Also, make sure the
has a pair closing tag.
Yes, I know that allegedly a paired closing tag not needed, but when dealing with .xsd files
I found out, the hard way, that .xml files will not display when the
tags aren't paired.
Maybe it's the same when parsing.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
======================================
"JB" <jamesb457 [at] gmail.com> wrote in message news:d0b8d242-254d-4e1d-9e55-db50f5bf6b91 [at] u12g2000prd.google groups.com...
On 8 Apr, 16:09, "vMike" <vM... [at] 5noerrawgespam.com> wrote:
> "JB" <jamesb... [at] gmail.com> wrote in message
>
> news:a6039f9e-2435-4bdd-a3cf-8d91a24afe2a [at] 1g2000prg.googlegr oups.com...
>
>
>
> > I'm returning a string from an xml file and trying to do something
> > like the following.
>
> > <Getter>
> > return HtmlEncode(s_tring.Value.Replace("\n","<br>"));
> > </Getter>
>
> > to replace a new-line character with a html line break.
> > But the "<BR>" is giving me errors as indicated in the title.
>
> > presumable it is parsing the string and thinking <br> is the start of
> > a new field in the xml file.
>
> > How can I go about reformatting it to let it through?
>
> > <?xml version="1.0" encoding="utf-8" ?> - if that effects things at
> > all. xml isnt my expertise :)
>
> You might try
> <Getter><![CDATA[return
> HtmlEncode(s_tring.Value.Replace("\n","<br>"));]]></Getter>
>
> vmike
I tried "<br/>" and that gives me the same error as before.
using <![CDATA[ ....]]
gives me 'This is an unexpected token. The expected token is '['. Line
1006, position 18. '
The stack trace is next to useless, just says there is a problem
reading the xml.
It works spot on if dont have the <br> in there, for example I replace
'\n' with '^' and its all good, but that doesnt help me format the
string :)