Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / April 2008

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JB - 08 Apr 2008 15:35 GMT
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 :)
Aidy - 08 Apr 2008 16:01 GMT
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.

> I'm returning a string from an xml file and trying to do something
> like the following.
[quoted text clipped - 13 lines]
> <?xml version="1.0" encoding="utf-8" ?> - if that effects things at
> all. xml isnt my expertise :)
vMike - 08 Apr 2008 16:09 GMT
> I'm returning a string from an xml file and trying to do something
> like the following.
[quoted text clipped - 13 lines]
> <?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
JB - 08 Apr 2008 16:34 GMT
> > I'm returning a string from an xml file and trying to do something
> > like the following.
[quoted text clipped - 19 lines]
>
> 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 :)
vMike - 08 Apr 2008 16:53 GMT
On 8 Apr, 16:09, "vMike" <vM...@5noerrawgespam.com> wrote:
> "JB" <jamesb...@gmail.com> wrote in message
>
[quoted text clipped - 23 lines]
>
> 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
Aidy - 08 Apr 2008 16:55 GMT
Tried using

&lt;br/&gt;

instead of <br/>?

On 8 Apr, 16:09, "vMike" <vM...@5noerrawgespam.com> wrote:
> "JB" <jamesb...@gmail.com> wrote in message
>
[quoted text clipped - 23 lines]
>
> 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 :)
Juan T. Llibre - 08 Apr 2008 17:07 GMT
Try : <br />

Notice the space between the "r" and the slash.
i.e., <br/> is wrong, but <br /> is OK.

Also, make sure the <br /> 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 <br /> 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/
======================================
On 8 Apr, 16:09, "vMike" <vM...@5noerrawgespam.com> wrote:
> "JB" <jamesb...@gmail.com> wrote in message
>
[quoted text clipped - 23 lines]
>
> 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 :)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.