Cannot convert from XMLElement[] to XMLElement
in
Programming Questions
•
2 years ago
Hi,
Daniel Groves
I'm pretty new to Processing, but am working on uni coursework for a Processing unit. For the coursework we have to visualise the data from the weather feed that runs one of the campus buildings. While doing this I have encountered the error "Cannot convert from XMLElement[] to XMLElement" in my BarGroup class, posted below.
Any help or feedback would be hugely appreciated as I am at complete loss.
- import processing.xml.*;
- class BarGroup
- {
- String xmlUrl;
- XMLElement xml = new XMLElement(getParent(), xmlUrl);
- XMLElement xmlValue = xml.getChildren("channel/item/description");
- float[] data = convertToFloat(xmlValue);
- int groupXpos
- Bar[] group = new Bar[3];
- // COnstructor
- BarGroup ( String url, int xPos)
- {
- xmlUrl = url;
- groupXpos = xPos;
- group[0] = new Bar( color(0, 255 ,0 ), 0, map( data[0], 0, highestValue(), 0, 600), (10 * 1) );
- group[1] = new Bar( color(0, 255 ,0 ), 0, map( data[1], 0, highestValue(), 0, 600), (10 * 2) );
- group[2] = new Bar( color(0, 255 ,0 ), 0, map( data[2], 0, highestValue(), 0, 600), (10 * 3) );
- }
- // Show the group of Bars
- void display()
- {
- for (int i = 0; i < 2; i++)
- {
- group[i].display();
- }
- }
- // Turn the XMLElement into an Array of Floats
- float[] convertToFloat( XMLElement[] toConvert )
- {
- String numberOne = toConvert[0].getContent();
- String numberTwo = toConvert[1].getContent();
- String numberThree = toConvert[2].getContent();
- println(numberOne);
- println(numberTwo);
- println(numberThree);
- float[] returnValues = new float[3];
- returnValues[0] = float(numberOne);
- returnValues[1] = float(numberTwo);
- returnValues[2] = float(numberThree);
- return returnValues;
- }
- // Find the biggest number
- float highestValue( float numberRange[] )
- {
- if ( numberRange[0] > numberRange[1] && numberRange[0] > numberRange[2] )
- {
- return numberRange[0];
- }
- else if ( numberRange[1] > numberRange[0] && numberRange[1] > numberRange[2])
- {
- return numberRange[1];
- }
- else if ( numberRange[2] > numberRange[0] && numberRange[2] > numberRange[1])
- {
- return numberRange[2];
- }
- }
- }
Daniel Groves
1