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.
Page Index Toggle Pages: 1
proXML online (Read 3599 times)
proXML online
Jul 21st, 2005, 12:20am
 
Hello

I uploaded the proXML lib, it allows Processing to read and write XML files. You can build a XML document by putting together different elements, or you can load an XML element from a certain url. When you have the XML-element filled with content you can save it as XML document.

Give it a try:

www.texone.org/proxml
Re: proXML online
Reply #1 - Jul 21st, 2005, 2:24am
 
Wonderful. I'll get it up on the Libraries page shortly.
Re: proXML online
Reply #2 - Jul 21st, 2005, 9:13am
 
Can I load XMLs from different sites then mine?
Re: proXML online
Reply #3 - Jul 21st, 2005, 2:15pm
 
You can only load XMLs  from your site. If you want to get documents from other sites, you need a php script to get it. I am thinking about writing a small java interface including the php scripts for simple loading of external files, but I need some more time for that. If you need a php script for loading files let me know I can post it here.
Re: proXML online
Reply #4 - Jul 22nd, 2005, 6:21pm
 
the simplest way of redirecting an xml file through php is just to use readfile();

<?php
readfile ('http://www.externalsiteurl.com/monkeys.xml');
?>
Re: proXML online
Reply #5 - Jul 23rd, 2005, 4:03pm
 
I have a so silly question about the library.

I can access elements and its attributes but, how can I access the node value?:

<text style="whatever">need to access this text</text>

?

Thanks.
Re: proXML online
Reply #6 - Jul 24th, 2005, 12:57am
 
Not sure if this is relevant, as I don't have a clue if this is allowed by the xml specifications.

I was using capital letters in the attribute names. proXML could not find any of these using getAttribute(), getIntAttribute() etc. So I had to change all to lower case which made it a little bit harder to read the attribute names.

Similar thing seems to be when reading strings from attributes. proXML ignores uppercase and prints it out as lowercase.
Re: proXML online
Reply #7 - Jul 24th, 2005, 1:42pm
 
Fixed the problem with the Capital letters, proxml was writting everything small.

Fixed text handling. Please be aware that text is treated as XMLElement. To get the text content of an XMLNode use getChild(). To test if it is a Text node use the isPCDATA() method.

proXML is able to work with mixed content.
Code:

<?xml version="1.0"?>
<text>some <what>text</what><where> here</where></text>

This results in text having the child XMLElements:
some
<what>
<where>

To build a text node use the contructor:
Code:

//XMLElement(String text,boolean pcDATA);
node.addChild(new XMLElement("text content",true));


I also fixed the save Problem. Saving is now possible with java versions lower than 1.5.

Check the new version:

www.texone.org/proxml
Re: proXML online
Reply #8 - Aug 6th, 2005, 12:11am
 
I'm getting an unexpected result with getAttribute, maybe you can have a look at it: I have several siblings who have an the same attribute value-- pos="c". I am trying to write an if statement to identify this attribute:

Code:

println(playerRef.getAttribute("pos"));
if (playerRef.getAttribute("pos")=="c") {
println("*");
}


This code generates a bunch of 'c's, but no asterisks. It looks as though the statement should be true, but it always comes up false.

I tried the following code, to see if I could figure out where the problem was occuring:
Code:


println(playerRef.getAttribute("pos"));

if (playerRef.getAttribute("pos") == playerRef.getParent().getChild(0).getAttribute("pos")) {
println("*");
}


Basically, comparing the attribute against the first child's attribute. This generates the following output:

Code:

c
*
c
c
c
c


Even though all the attributes are the same, it treats only the first one as a match. Any suggestions you have on why this isn't working for me would be greatly appreciated. Keep up the great work.
Re: proXML online
Reply #9 - Aug 6th, 2005, 1:49am
 
Code:

println(playerRef.getAttribute("pos"));
if (playerRef.getAttribute("pos").equals("c")) {
println("*");
}


This should work. Comparing Strings is a little bit different from comparing primitive types like int, float etc.
Re: proXML online
Reply #10 - Aug 13th, 2005, 4:55am
 
hey, i'm a noob to processing so please be gentle...

i have a MySQL database back-end which i'm accessing from flash & Processing by having PHP spit out XML. i've gotten this to work with flash fine & it works with processing using proXML when i run it in the IDE, buuuut, i get the following error when trying to run it in firefox:

proxml.InvalidDocumentException: http://my.remote.server/project/xml.php is not a parsable URL

is this a java applet security thing perhaps or am i just missing something here?

thanks in advance.
Re: proXML online
Reply #11 - Aug 13th, 2005, 12:55pm
 
When it is working in the IDE, but not as applet, it should be a security problem. Using an applet you can only access files located in the applets folder, or in the applets folders subfolders.

Is your processing applet located under  http://my.remote.server/project/?
Re: proXML online
Reply #12 - Aug 13th, 2005, 7:53pm
 
thanks tex. i was trying to load the applet locally on my machine which had security probs, but it works fine on the server. turns out that the applet can actually access any files on the same server. the directory structure doesn't matter. my xml.php file is in one branch of the document root & the applet is in a completely diferent branch off of the root & they both work fine now. cheers!
Page Index Toggle Pages: 1