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 & HelpPrograms › XML display using proXML
Page Index Toggle Pages: 1
XML display using proXML (Read 535 times)
XML display using proXML
Jan 5th, 2006, 1:10am
 
Hi there,

First time poster, so don't be too harsh :) !

I've recently tried to write a program incorporating proXML and would like to extend it to the GoogleAPI if possible, but I digress. My basic problem is that I can display everything from an XML document in the prompt window but not in the applet window, which I can only get one line.

My code may seem illogical at first as I have essentially modified (albeit heavily) the example from the proXML site. Apologies for the heavy commenting (bad habit)

-----------------------------------------------------------------

Code:

//import packages
import proxml.*;

//proXML reqs
XMLElement feeds;
XMLInOut xmlInOut;


//setup method
void setup()
{
size(640,400);
smooth();
background(102);


//load fonts
PFont font = loadFont("Verdana-10.vlw");
textFont(font, 10);

//load feeds from file if it exists
try
{
xmlInOut = new XMLInOut(this);

//test with BBC E Commerce website
feeds = xmlInOut.loadElementFrom("http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/business/rss.xml");


for (int x=0 ; x<=feeds.countAllChildren(); x++)
{
text(feeds.toString(),15,20);
}

initFeeds();
}


catch(InvalidDocumentException ide)
{
println("Bad Link");
}

}


void draw()
{
}

void initFeeds()
{
//test to make sure that the xml file is read fully
feeds.printElementTree(" "," ");
}



This displays the whole XML document in the prompt but only the first line in the applet window.

Now I know the problem is with my for loop in the setup, but I can't simply replace the toString with the printElementTree.

Eventually, I want to be able to pull only specific tags out of the whole document and only have the news headings displayed as clickable links, but firstly I need to be able to display the document first!

Apologies for the long code.

Thanks for anyone who can help.
Page Index Toggle Pages: 1