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 & HelpSyntax Questions › xml, xmlPro, whatever
Pages: 1 2 
xml, xmlPro, whatever (Read 6890 times)
xml, xmlPro, whatever
Nov 4th, 2008, 9:30pm
 
Hi,

i need to create a xml file but i got so much troubles.

with processing.xml apparently is not possible to create a xml file, i mean i won't use println to write my xml file. i tried to use createElement but it doesn't works i don't know why.

Anyway i have installed proXML library but apparently it has some problems with the processing xml library, if i use XMLElement(and i need it) it say XMLElement is ambiguous.


Anybody has tried it before? can you give me some suggestions or/and some pieces of code?


Q
Re: xml, xmlPro, whatever
Reply #1 - Nov 5th, 2008, 2:00am
 
Because the processing xml library is imported by default it causes a name collision with proXML. You get around it by being specific with declaring the variables.

Code:

//http://www.texone.org/proxml/
import proxml.*;

// create the root element be specific where the class is
proxml.XMLElement file = new proxml.XMLElement("root");

// create the color element
proxml.XMLElement col = new proxml.XMLElement("color");

// add some attributes to it.
col.addAttribute("r", random(255));
col.addAttribute("g", random(255));
col.addAttribute("b", random(255));

// make the color element a child of the root element
file.addChild(col);

// create an XMLInOut object to format the elements
XMLInOut xmlInOut = new XMLInOut(this);

// and call saveElement.
xmlInOut.saveElement(file, "saving_color.xml");

Re: xml, xmlPro, whatever
Reply #2 - Nov 5th, 2008, 9:38am
 
thank you so much, the code works perfectly, i was stucked on that.

Q
Re: xml, xmlPro, whatever
Reply #3 - Nov 6th, 2008, 7:50pm
 
Nice!  Thanks, Polymonkey.  I was having this issue, too.
Re: xml, xmlPro, whatever
Reply #4 - Nov 6th, 2008, 9:15pm
 
No problem. One thing though. If you need to use both in the one sketch then you can get to the processing xml by using this

Code:

processing.xml.XMLElement foo = new processing.xml.XMLElement("chicken");


Re: xml, xmlPro, whatever
Reply #5 - Jan 4th, 2009, 11:55pm
 
i have this piece of code and when executing the script it gives me and error for the last line.  


 xmlInOut = new XMLInOut(this);
 try{
   xmlInOut.loadElement("data.xml");
 }
 catch(Exception e){
   xmlEvent(new XMLElement("stuff"));
 }

"The type XMLElement is ambigious.

I tried to write
proxml.xmlEvent (new proxml.XMLElement("stuff"));

then i get: "Cannot find anything named proxml"

any idea what might be wrong?
thanks a lot
Re: xml, xmlPro, whatever
Reply #6 - Jan 5th, 2009, 1:20am
 
this might be a silly question, but did you import the proxml library?
Re: xml, xmlPro, whatever
Reply #7 - Jan 5th, 2009, 7:05am
 
Wink no, not silly at all..
yes i've imported the library, because all the other functions work....
when usingproxml.XMLElement file = new proxml.XMLElement("root");
this works perfectly well
Re: xml, xmlPro, whatever
Reply #8 - Jan 30th, 2009, 11:16pm
 
polymonkey wrote on Nov 5th, 2008, 2:00am:
Because the processing xml library is imported by default it causes a name collision with proXML. You get around it by being specific with declaring the variables.

Code:

//http://www.texone.org/proxml/
import proxml.*;

// create the root element be specific where the class is
proxml.XMLElement file = new proxml.XMLElement("root");




Thanks. I was stuck with this too!
Re: xml, xmlPro, whatever
Reply #9 - Feb 5th, 2009, 7:19pm
 
Hi everyone,

I think I must be missing something here.
I'm getting the "The type XMLElement is ambiguous" error too, but I don't understand how to apply this solution to my code.
I'm using the code from http://www.bryanchung.net/?p=188 as a template (which I will be adapting later).

Apologies if its really obvious, but any help would be much appreciated!!

Cheers.
Re: xml, xmlPro, whatever
Reply #10 - Feb 5th, 2009, 9:34pm
 
mselby wrote on Feb 5th, 2009, 7:19pm:
Hi everyone,

I think I must be missing something here.
I'm getting the "The type XMLElement is ambiguous" error too, but I don't understand how to apply this solution to my code.
I'm using the code from http://www.bryanchung.net/?p=188 as a template (which I will be adapting later).



Anywhere where XMLElement is used, such as

void parseXML(XMLElement _x) { ..

specify that it is the proxml version of XMLElement like so

void parseXML(proxml.XMLElement _x) { ..

Hope this helps.
Re: xml, xmlPro, whatever
Reply #11 - Feb 6th, 2009, 10:59am
 
Of Course!!

Thanks very much, that was really getting on my nerves!
Re: xml, xmlPro, whatever
Reply #12 - Aug 25th, 2009, 3:45pm
 
polymonkey wrote on Nov 5th, 2008, 2:00am:
Because the processing xml library is imported by default it causes a name collision with proXML. You get around it by being specific with declaring the variables.

Code:

//http://www.texone.org/proxml/
import proxml.*;

// create the root element be specific where the class is
proxml.XMLElement file = new proxml.XMLElement("root");

// create the color element
proxml.XMLElement col = new proxml.XMLElement("color");

// add some attributes to it.
col.addAttribute("r", random(255));
col.addAttribute("g", random(255));
col.addAttribute("b", random(255));

// make the color element a child of the root element
file.addChild(col);

// create an XMLInOut object to format the elements
XMLInOut xmlInOut =  new XMLInOut(this);

// and call saveElement.
xmlInOut.saveElement(file, "saving_color.xml");



this is not working for me ... Huh

Any other solution?

I think xml writing should be in the core lib of P5...
Re: xml, xmlPro, whatever
Reply #13 - Aug 26th, 2009, 6:56am
 
The code you show works for me.
It writes the file in the data folder of the sketch...
Re: xml, xmlPro, whatever
Reply #14 - Aug 26th, 2009, 11:20am
 
leanderlike wrote on Jan 4th, 2009, 11:55pm:
I tried to write
proxml.xmlEvent (new proxml.XMLElement("stuff"));

then i get: "Cannot find anything named proxml"


i get exactly the same error. any ideas how to solve this
Pages: 1 2