-
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
-
up to my .as in code
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
-
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?
-
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?
-
up to my .as in code
Have the developer switch the way he codes xml documents to a more mature structure.
-
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!
-
OOP is one letter from OOPS
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" />
-
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?
-
up to my .as in code
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.
-
up to my .as in code
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.
Last edited by Chris_Seahorn; 06-05-2006 at 10:29 AM.
-
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.
-
up to my .as in code
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
-
Yeah, we're cool! No offence taken, at all. Thanks again.
-
OOP is one letter from OOPS
Ahh I see what you mean. Seems like you got it worked out.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|