We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi everyone,
I am new to Processing and the first project I am working on is a visual representation of an xml document. Each element will be a box in the visual space, and when clicked, it generates boxes for each of that nodes children. So far I have played with the XML documentation on the site, but I can't seem to get what I need from them. Currently, this is my XML document:
<?xml version="1.0"?>
<root>
<child>
<subchild id="0">
<item1>
Item 1 Content
</item1>
<item2>
Item 2 Content
</item2>
<item3>
Item 3 Content
</item3>
</subchild>
<subchild id="1">
<item1>
Item 1 Content
</item1>
<item2>
Item 2 Content
</item2>
<item3>
Item 3 Content
</item3>
</subchild>
<subchild id="2">
<item1>
Item 1 Content
</item1>
<item2>
Item 2 Content
</item2>
<item3>
Item 3 Content
</item3>
</subchild>
</child>
</root>
My goal is to have a Node object, and in it, it can start at the root and create new objects for each children and so on. I am running into problems even getting the child elements to show up properly. Does anyone have tips, similar patches, or resources that I can use for XML in Processing 2?
Thanks, Austin
Answers
You posted in Questions about Code, so you should show your code, so we can find out what you did wrong, and fix it.
Here is the first tab:
and the second:
I just didn't include it in the first post because it is very rough and I have torn it apart trying to get the XML to work.
this reads a text-file
it needs a csv file in the data folder - see below
maybe it helps...
You can specify which kind of children you want in getChildren(), like getChildren("child") or getChildren("item").
This allows to get more precise information.
ok, I modified your xml file:
ok, I modified your xml file:
ok, I modified your xml file:
wanted to post the new xml-file but were not possible (xml) but then the forum gave me 600 seconds block (because I was suspect of spamming)........ argh....
anyway it posted my message despite the error message
here is the new code - based on your code
but I don't feel the approach is correct
because when one subchild had a child, we coudn't display it
also when it had a child we want that also to be a node (so with frame and expendable)
So maybe we have to have an arraylist of nodes and each node knows what children (and parent) it has
That would make the class Node very slim / lean
the error message now always shows up in this thread but he posts anyway - just hit F5
Good luck!
here is what I meant - a Node is only one item
I'll start pulling this apart and try it out! Sorry for the delayed response!