www.webdeveloper.com
Results 1 to 3 of 3

Thread: xml in pre tag

  1. #1
    Join Date
    Apr 2010
    Posts
    4

    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. How do I get raw text from the pre? 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.

    HTML Code:
    <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>

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    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.

  3. #3
    Join Date
    Apr 2010
    Posts
    4
    Quote Originally Posted by rnd me View Post
    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.
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles