Reading XML File, "<br>" gives "Element" is not a valid node type

Reading XML File, "<br>" gives "Element" is not a valid node type

am 08.04.2008 16:35:05 von jamesb457

I'm returning a string from an xml file and trying to do something
like the following.


return HtmlEncode(s_tring.Value.Replace("\n","
"));


to replace a new-line character with a html line break.
But the "
" is giving me errors as indicated in the title.

presumable it is parsing the string and thinking
is the start of
a new field in the xml file.

How can I go about reformatting it to let it through?



- if that effects things at
all. xml isnt my expertise :)

Re: Reading XML File, "<br>" gives "Element" is not a valid node type

am 08.04.2008 17:01:24 von Aidy

Not really sure what you're doing, but in xml "
" is not valid, try this
instead;

return HtmlEncode(s_tring.Value.Replace("\n","
"));

Note the forward slash after the br but before the closing bracket.

"JB" wrote in message
news:a6039f9e-2435-4bdd-a3cf-8d91a24afe2a@1g2000prg.googlegr oups.com...
> I'm returning a string from an xml file and trying to do something
> like the following.
>
>
> return HtmlEncode(s_tring.Value.Replace("\n","
"));
>

>
> to replace a new-line character with a html line break.
> But the "
" is giving me errors as indicated in the title.
>
> presumable it is parsing the string and thinking
is the start of
> a new field in the xml file.
>
> How can I go about reformatting it to let it through?
>
>
>
> - if that effects things at
> all. xml isnt my expertise :)
>

Re: Reading XML File, "<br>" gives "Element" is not a valid node type

am 08.04.2008 17:09:59 von vMike

"JB" wrote in message
news:a6039f9e-2435-4bdd-a3cf-8d91a24afe2a@1g2000prg.googlegr oups.com...
> I'm returning a string from an xml file and trying to do something
> like the following.
>
>
> return HtmlEncode(s_tring.Value.Replace("\n","
"));
>

>
> to replace a new-line character with a html line break.
> But the "
" is giving me errors as indicated in the title.
>
> presumable it is parsing the string and thinking
is the start of
> a new field in the xml file.
>
> How can I go about reformatting it to let it through?
>
>
>
> - if that effects things at
> all. xml isnt my expertise :)


You might try
HtmlEncode(s_tring.Value.Replace("\n","
"));]]>


vmike

Re: Reading XML File, "<br>" gives "Element" is not a valid node type

am 08.04.2008 17:34:05 von jamesb457

On 8 Apr, 16:09, "vMike" wrote:
> "JB" wrote in message
>
> news:a6039f9e-2435-4bdd-a3cf-8d91a24afe2a@1g2000prg.googlegr oups.com...
>
>
>
> > I'm returning a string from an xml file and trying to do something
> > like the following.
>
> >
> > =A0 =A0return HtmlEncode(s_tring.Value.Replace("\n","
"));
> >

>
> > to replace a new-line character with a html line break.
> > But the "
" is giving me errors as indicated in the title.
>
> > presumable it is parsing the string and thinking
is the start of
> > a new field in the xml file.
>
> > How can I go about reformatting it to let it through?
>
> > - if that effects things at
> > all. xml isnt my expertise :)
>
> You might try
> > HtmlEncode(s_tring.Value.Replace("\n","
"));]]>

>
> vmike

I tried "
" and that gives me the same error as before.

using 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
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

am 08.04.2008 17:53:44 von vMike

"JB" wrote in message
news:d0b8d242-254d-4e1d-9e55-db50f5bf6b91@u12g2000prd.google groups.com...
On 8 Apr, 16:09, "vMike" wrote:
> "JB" wrote in message
>
> news:a6039f9e-2435-4bdd-a3cf-8d91a24afe2a@1g2000prg.googlegr oups.com...
>
>
>
> > I'm returning a string from an xml file and trying to do something
> > like the following.
>
> >
> > return HtmlEncode(s_tring.Value.Replace("\n","
"));
> >

>
> > to replace a new-line character with a html line break.
> > But the "
" is giving me errors as indicated in the title.
>
> > presumable it is parsing the string and thinking
is the start of
> > a new field in the xml file.
>
> > How can I go about reformatting it to let it through?
>
> > - if that effects things at
> > all. xml isnt my expertise :)
>
> You might try
> > HtmlEncode(s_tring.Value.Replace("\n","
"));]]>

>
> vmike

I tried "
" and that gives me the same error as before.

using 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
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
in it using


HtmlEncode(s_tring.Value.Replace("\n","
"));]]>



Mike

Re: Reading XML File, "<br>" gives "Element" is not a valid node type

am 08.04.2008 17:55:25 von Aidy

Tried using

<br/>

instead of
?

"JB" wrote in message
news:d0b8d242-254d-4e1d-9e55-db50f5bf6b91@u12g2000prd.google groups.com...
On 8 Apr, 16:09, "vMike" wrote:
> "JB" wrote in message
>
> news:a6039f9e-2435-4bdd-a3cf-8d91a24afe2a@1g2000prg.googlegr oups.com...
>
>
>
> > I'm returning a string from an xml file and trying to do something
> > like the following.
>
> >
> > return HtmlEncode(s_tring.Value.Replace("\n","
"));
> >

>
> > to replace a new-line character with a html line break.
> > But the "
" is giving me errors as indicated in the title.
>
> > presumable it is parsing the string and thinking
is the start of
> > a new field in the xml file.
>
> > How can I go about reformatting it to let it through?
>
> > - if that effects things at
> > all. xml isnt my expertise :)
>
> You might try
> > HtmlEncode(s_tring.Value.Replace("\n","
"));]]>

>
> vmike

I tried "
" and that gives me the same error as before.

using 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
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

am 08.04.2008 18:07:25 von nomailreplies

Try :


Notice the space between the "r" and the slash.
i.e.,
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" wrote in message news:d0b8d242-254d-4e1d-9e55-db50f5bf6b91@u12g2000prd.google groups.com...
On 8 Apr, 16:09, "vMike" wrote:
> "JB" wrote in message
>
> news:a6039f9e-2435-4bdd-a3cf-8d91a24afe2a@1g2000prg.googlegr oups.com...
>
>
>
> > I'm returning a string from an xml file and trying to do something
> > like the following.
>
> >
> > return HtmlEncode(s_tring.Value.Replace("\n","
"));
> >

>
> > to replace a new-line character with a html line break.
> > But the "
" is giving me errors as indicated in the title.
>
> > presumable it is parsing the string and thinking
is the start of
> > a new field in the xml file.
>
> > How can I go about reformatting it to let it through?
>
> > - if that effects things at
> > all. xml isnt my expertise :)
>
> You might try
> > HtmlEncode(s_tring.Value.Replace("\n","
"));]]>

>
> vmike

I tried "
" and that gives me the same error as before.

using 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
in there, for example I replace
'\n' with '^' and its all good, but that doesnt help me format the
string :)