A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: ' and & - a wrinkle to the special character problem

  1. #1
    Board Idiot num97's Avatar
    Join Date
    Jun 2004
    Location
    South of Heaven
    Posts
    194

    ' and & - a wrinkle to the special character problem

    Hi all.

    I have seen people having a similar problem as I am having, but mine's a tad different.

    I have written some code that builds an XML file from ID3 information from mp3's. I have all the code fine, but when I trace the XML file, apostrophes and ampersands are represented as &apos and &amp repsectively. How do I convert these back to the original information within flash? I have seen escape and unescape used, but for the life of me, cannot figure out how to change it.

    Any input would be greatly appreciated.
    I don't have a bad sex life and I have the pictures to prove it.

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    try tracing the nodeValue

    ie .. "Tate & Lyle"
    parse and trace as xmlObj.firstChild - ouputs - "Tate & Lyle"
    parse and trace as xmlObj.firstChild.nodeValue - ouputs - "Tate & Lyle"

    or output to an html enabled textfield

  3. #3
    Board Idiot num97's Avatar
    Join Date
    Jun 2004
    Location
    South of Heaven
    Posts
    194
    I think I see what you are saying. If I use just .firstChild, I will get the funky characters, whereas .firstChild.nodeValue will give the actual characters.

    I'll give it a shot tonight - thanks!
    I don't have a bad sex life and I have the pictures to prove it.

  4. #4
    Board Idiot num97's Avatar
    Join Date
    Jun 2004
    Location
    South of Heaven
    Posts
    194
    My code works like this - I build an array with the information I need, then I populate an XML file with it.

    What you are suggesting is for outputting from an XML file, correct? My issue is populating the XML file, I think.

    Let me explain what I have done.

    I started with an XML file I manually typed out. Here is the general layout:
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <tracklist>
    	<Song track="" title="" link=""/>
    </tracklist>
    The <Song/> node has the attributes "track", "title", and "link" which are populated from the ID3 data (track and title) and a FileReferenceList (for the link). The attributes are where I'm getting the funny characters (specifically the title and link). For the title, I don't really care, but the link is to an mp3 file on my server and therefore needs to be accurate.

    The XML file is populated correctly except for the characters. Is there a work-around I can use within flash?
    I don't have a bad sex life and I have the pictures to prove it.

  5. #5
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    have you tried String.split, String.join ?
    Code:
    str = "$£split*this£$"
    trace(str);
    str = str.split("$").join("").split("£").join("").split("*").join(" ");
    trace(str);

  6. #6
    Board Idiot num97's Avatar
    Join Date
    Jun 2004
    Location
    South of Heaven
    Posts
    194
    Tried it tonight and that didn't work.

    What is it about XML within flash that doesn't like & and '? The ID3 data is correct. I traced it and those characters are correct. However, when it's moved to the XML object and then traced, they are altered to &amp; and &apos;.

    Is there a routine that goes through each word in an XML file and replaces them?
    I don't have a bad sex life and I have the pictures to prove it.

  7. #7
    Member
    Join Date
    Nov 2006
    Posts
    63
    Here is a link that will probably help you out:

    http://www.w3schools.com/xml/xml_cdata.asp

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center