/    Sign up×
Community /Pin to ProfileBookmark

xml in pre tag

I want to read a pre tag with xml. I am working client side. I have tried everything. The <title> tag gets lost with innerHTML(ok in FF only). I tried traversing the dom and putting in the tag names but the title tag is ignored. I am trying to syntax highlight this. Everything works if I do not use certain html tags. [B]How do I get raw text from the pre?[/B] The text would come from one of two sources, a server or inputted into a textarea by the user. It is dynamically placed in the div tag and then processed.

[code=html]<div id=”xml”>

<pre>
<collection>
<cd>
<title>Fight for your mind</title>
<artist>Ben Harper</artist>
<year>1995</year>
</cd>
<cd>
<title>Electric Ladyland</title>
<artist>Jimi Hendrix</artist>
<year>1997</year>
</cd>
</collection>
</pre>

</div>[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@rnd_meApr 05.2010 — you have to escape the xml before it goes in the pre tag.

for example, you need to turn ">" into "&gt;", "<" into "&lt;" and so on...

you can also use a textarea, which can contain any XML except "</textarea>", but you can't highlight the textatrea text.
Copy linkTweet thisAlerts:
@mrteaauthorApr 05.2010 — you have to escape the xml before it goes in the pre tag.

for example, you need to turn ">" into "&gt;", "<" into "&lt;" and so on...

you can also use a textarea, which can contain any XML except "</textarea>", but you can't highlight the textatrea text.[/QUOTE]


Yes, the escaping was being done when pulling from the server or textarea. I tried the textarea tag but I use it in a textarea so the second tag killed that as you mentioned.

It turned out that the problem was a combination of sequence of processing and cache issues. It has been resolved. Thanks.
×

Success!

Help @mrtea spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...