We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › proXML url parsing issue
Page Index Toggle Pages: 1
proXML url parsing issue (Read 2593 times)
proXML url parsing issue
Jan 25th, 2006, 6:52pm
 
Hello

It seems as though the url parser for the proXML library only handles certain domain names/DNS properly, and not IP addresses & bonjour names.

For example, the following code works in my applet:

Code:

shareAtomFeedIO = new XMLInOut(this);
// load the Atom Feed from the URL.
shareAtomFeed = shareAtomFeedIO.loadElementFrom("http://share.dj/share/feeds/Multimedia.xml");


this does not:
Code:

shareAtomFeedIO = new XMLInOut(this);
// load the Atom Feed from the URL.
shareAtomFeed = shareAtomFeedIO.loadElementFrom("http://hokkaido.local/share/feeds/Multimedia.xml");


nor does

Code:

shareAtomFeedIO = new XMLInOut(this);
// load the Atom Feed from the URL.
shareAtomFeed = shareAtomFeedIO.loadElementFrom("http://127.0.0.1/share/feeds/Multimedia.xml");


I do not get a url lookup error, I recieve a:

Code:

proxml.InvalidDocumentException: This is not a parsable URL
at proxml.XMLInOut.handleStartTag(XMLInOut.java:459)

java.lang.NullPointerException
at Temporary_902_5427.parseAtomXML(Temporary_902_5427.java:120)
at Temporary_902_5427.setup(Temporary_902_5427.java:34)
at processing.core.PApplet.display(PApplet.java:1259)
at processing.core.PGraphics.requestDisplay(PGraphics.java:520)
at processing.core.PApplet.run(PApplet.java:1142)
at java.lang.Thread.run(Thread.java:552)


Is there a chance that proXML could be updated to work with localhost, 127.0.0.1 and rendez... bonjour .local name spaces?

Thank you.
Re: proXML url parsing issue
Reply #1 - Jan 25th, 2006, 6:56pm
 
Also, valid long urls dont seem to be parsed.

this is a valid url, which also throws that error:

http://colab.hunter.cuny.edu/colabcms/feeds/Multimedia.xml

Thoughts?
Re: proXML url parsing issue
Reply #2 - Jan 25th, 2006, 9:04pm
 
Thanks for posting the examples I will take a look on it on the weekend.
Re: proXML url parsing issue
Reply #3 - Jan 26th, 2006, 5:41am
 
No worries. Thanks for the library, btw, I met your partner Markus at Share in NYC, the version of >tree< with audio is really mesmerizing - beautifully done!

Heres the Share link : btw http://share.dj/share/event_info.php?eventID=296
Re: proXML url parsing issue
Reply #4 - Feb 3rd, 2006, 11:52am
 
Okay I checked it

No idea with the local stuff, I will take a look on that if I have more time.

http://colab.hunter.cuny.edu/colabcms/feeds/Multimedia.xml

This is not working because
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
is missing to make it a valid xml document.

proXML first checks this line because this makes it easy to ensure you really load XML so proXML is not getting into trouble, maybe I will enable proXML to load XML files without this startline.
Re: proXML url parsing issue
Reply #5 - Mar 15th, 2006, 4:57pm
 
While I realize that there's a good reason to not parse invalid XML, there are times when someone wants to do so...if you have webspace with PHP you can circumvent this issue with proXML by making a page that is a proxy for the XML you're trying to parse, e.g.,
Code:
<?
header("Content-type: text/xml; charset=UTF-8");
$someurl = "http://colab.hunter.cuny.edu/colabcms/feeds/Multimedia.xml";

$xml = get_file_safely($someurl);

$xml = (preg_match("#^<\?\s?xml\s*version=.+?\?>#", $xml)) ? $xml : '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'.$xml;

echo $xml;

function get_file_safely($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$rawhtml = curl_exec ($ch);
curl_close ($ch);

return $rawhtml;
}
?>

where $someurl is the .xml file URL you're trying to parse.  

If you copy the code above into a file on your server and rename it something like xmlfixer.php, it will take an XML file and look to see if it's missing the beginning <?xml... tag, and add it if it's not there.  All you need to do is point proXML at the php file as the URL.
Page Index Toggle Pages: 1