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 › A Noobies XML Headache
Page Index Toggle Pages: 1
A Noobies XML Headache (Read 494 times)
A Noobies XML Headache
Dec 19th, 2009, 4:07pm
 
Hi just started using processing to aid my Arduino development, and have just ran into a brick wall.

So far I have rect that travels along the path of a line, which is positioned manually.

My initial goal is to calculate the position of the line with data from an xml file and have the rect go along that line, however I do not know how to access deep enough to get to the relevant data in my file.

Here is a snippet of the file:
Code:
- <slice>
- <dimension>
 <x>44.97449</x>
 <y>43.25116</y>
 <z>10.0</z>
 </dimension>
- <para>
 <layerheight>10.0</layerheight>
 <layerpitch>1.0</layerpitch>
 <speed>1.0</speed>
 </para>
- <layers num="1">
- <layer id="1">
- <loops num="6">
- <loop id="1">
- <line>
- <point>
 <x>9.74318372</x>
 <y>2.10971198</y>
 <z>-2.6</z>
 </point>
- <point>
 <x>9.743058</x>
 <y>2.11195086</y>
 <z>-2.6</z>
 </point>
 </line>


It is the X, Y data from point I am trying to get.

Can anyone point me in the right direction please?

^_^

EDIT: Oh I see... nevermind I posted too soon
Code:
 String s2x = xml.getChild(2).getChild(0).getChild(0).getChild(0).getChild(0).getChild(0).getChild(0).getContent();
 String s2y = xml.getChild(2).getChild(0).getChild(0).getChild(0).getChild(0).getChild(0).getChild(1).getContent();

works nicely for me, seems messy though
Re: A Noobies XML Headache
Reply #1 - Dec 20th, 2009, 12:43am
 
Try something like:

tempXml = xml
while ( tag for tempXml is not point )
 tempXml = tempXml.getChild


That should give you cleaner code.
Page Index Toggle Pages: 1