A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: Pipe character in URL from XML causes broken link, please help.

  1. #1
    Senior Member
    Join Date
    Oct 2000
    Posts
    138

    Pipe character in URL from XML causes broken link, please help.

    Hi,

    Im currently have a flash file that is pulling in information from an xml file.

    Within the XML there is a url that needs to be opened via the swf into a new window, but for some reason, the flash only reads the url up to the pipe character '|'

    All the other links previously don not have the pipe character and work fine..... can someone help??

    Thanks

  2. #2
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Wrap it in a CDATA section so the parser will ignore it. This way you can still push it's value to a clickable object within your movie.

    Using this xml ( I named it freeky.xml):

    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <main>
     <item>
    	<link><![CDATA[http://www.pathtosomeserver.com/index.php|toload]]></link> 
     </item>
    </main>
    Which has a bogus link with a pipe I can use this script in an empty movie to test:

    Code:
    _root.createTextField("mydata",1,40,40,300,100);
    mydata.multiline = true;
    mydata.wordWrap = true;
    mydata.border = false;
    mydata.html = true;
    
    myXML = new XML();
        myXML.ignoreWhite = true;
        myXML.onLoad = function(success) {
            if (success) {
         _root.mydata.htmlText = this.firstChild.childNodes[0].childNodes[0];
        
      
    }
    }
    myXML.load("freeky.xml");
    
    stop();
    and it will not halt the parser as shown live here:

    http://actionscript.hobby-site.com/examples/freeky.html

  3. #3
    Senior Member
    Join Date
    Oct 2000
    Posts
    138
    Thank you for your help.

    Unfortuntely it doesnt solve the problem.

    I am working with someone else regards the problem, and they state that the CDATA tag can't be used as element attributes for the situation we are working with.

    Is there any other way around?

  4. #4
    Junior Member
    Join Date
    Jun 2006
    Posts
    5
    Yeah, how can you solve the problem if the XML is in this format?

    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <main>
     <item>
        <link url="http://www.pathtosomeserver.com/index.php|toload" />
      </item>
    </main>
    You can't do

    Code:
    <link url="<![CDATA[http://www.pathtosomeserver.com/index.php|toload]]>" />
    that can you?

  5. #5

  6. #6
    Junior Member
    Join Date
    Jun 2006
    Posts
    5
    Well - regardless of what you think of the XML application design - it is valid XML and Flash shouldn't choke on the pipe character the way it does!

  7. #7
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    What is the pipe character doing? Is toLoad a command? why not just store it in a speperate attribute in the same node and then just refernce in the code and avoid the pipe problem all together?
    <link url="http://www.pathtosomeserver.com/index.php" cmd ="toload" />
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  8. #8
    Junior Member
    Join Date
    Jun 2006
    Posts
    5
    Quote Originally Posted by kortex
    why not just store it in a speperate attribute in the same node and then just refernce in the code and avoid the pipe problem all together?
    You can only do that if the site you control the site you are linking to - which isn't always the case!

    So is this a bug in Flash? Is there no workaround for it?

  9. #9
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Hey ..you have a url with a pipe...that's your business. Since I don't I cannot run a live link so you'll have to trust me that this will hit a live one you have that does.

    Create an empty movie with a button that has an instance name of "but1_btn".

    This xml (i named razor2.xml):

    Code:
    <?xml version="1.0"?>
    <item>
    <link url="http://www.pathtosomeserver.com/index.php%7Ctoload" />
    </item>
    uses the urlencoded value for"|" and with this script in that button movie:

    Code:
    myXML = new XML();
        myXML.ignoreWhite = true;
        myXML.onLoad = function(success) {
            if (success) {
          
         _root.foo = this.firstChild.childNodes[0].attributes.url;
       
        
    }
    }
    myXML.load("http://actionscript.hobby-site.com/examples/razor2.xml");
    
    _root.but1_btn.onPress=function(){
    getURL(""+_root.foo,"_blank");
    }
    stop();
    You should be getting in the ballpark.

  10. #10
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Kortex...the "toload" thing was my creation. He posted no link as example to copy and simply stated he had a pipe in the addy...so I made a fake addy with a pipe.

    For the record...any designer who created an xml routine that needs to use a pipe but did not have the foresight to support CDATA sections (as you state he did not)....is a designer I need to avoid. Just because an xml file is valid...does not mean it is good.

  11. #11
    Junior Member
    Join Date
    Jun 2006
    Posts
    5
    The designer of the XML application and the designer of the URL format for the website are two different people working at two different companies (indeed, they're part of two different websites). Neither developer has the power to dictate a format to the other. And we just have to accomodate the needs of everyone as best we can!

    Thanks for the help though, URL encoding the pipe worked a treat. Now I'm off to give myself fifty lashes for not thinking of that myself!
    Last edited by Marwood; 06-05-2006 at 10:41 AM.

  12. #12
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Cool. I didn't want you disliking me while I was trying to help. I understand your situation and I really am glad she's up and running. Hope we are cool.

    Chris

  13. #13
    Junior Member
    Join Date
    Jun 2006
    Posts
    5
    Yeah, we're cool! No offence taken, at all. Thanks again.

  14. #14
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    Ahh I see what you mean. Seems like you got it worked out.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


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