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 › newbie xml - text outer tags
Page Index Toggle Pages: 1
newbie xml - text outer tags (Read 505 times)
newbie xml - text outer tags
Feb 2nd, 2009, 2:52pm
 
Hi,

I just started to use the proXML library.
It works fine, but I am confused by one thing.
I want to read the title, which is not given in the tag.
so it`s easy to get the title attribute "someTitle"  
but I need to read "ZEIT ONLINE: Deutschland".

If you think this is to stupid to be posted, please let me know!


example .xml:
_________________________

<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
<channel>
<title attr="someTitle">ZEIT ONLINE:  Deutschland</title>
<link>http://www.zeit.de/deutschland/index</link>
<description>
Neues aus Deutschland : Aktuelles aus den deutschen Bundesländern
</description>
</channel>
</rss>
______________

.pde:
_______________


import proxml.*;


XMLInOut xmlIO;
XMLElement  title;
XMLElement news1;
XMLElement  channel;


void setup(){
 size(400,400);
 xmlIO = new XMLInOut(this);
 xmlIO.loadElement("zeit_exp.xml");    //read testfile  
}

void xmlEvent(XMLElement element){
 news1=element;
 channel=news1.getChild(0);
 // println(channel);
 title=channel.getChild(0);
 println(title);
  }

void draw(){

}


_____________________________

...everything failed - somebody can help?
Re: newbie xml - text outer tags
Reply #1 - Feb 2nd, 2009, 3:32pm
 
Do you need proXML? For this task at least, built-in XML support is enough:
Code:
XMLElement xml;

void setup()
{
xml = new XMLElement(this, "rss.xml"); // rss
println(xml.getName());
XMLElement e = xml.getChild(0); // channel
println(e.getName());
e = e.getChild(0); // title
println(e.getName());
String t = e.getContent();
println(t);
}

Looking at proXML's API, perhaps what is missing is a call to getText().
Page Index Toggle Pages: 1