OK, so I have some xml that looks like this basically:
This data is stored on a web service, and I have the cod written to the point where I can get this data, and then iterate through it in some fashion. Right now I am able to tell my program to go through each project in the project collection, and for each one take the <name text value and add it to a list. Of course I can also do so with projectId, permissions, deices, and channels.
But this leaves me with a bunch of lists loaded up with a bunch of values, and no way to connect them. The end goal is to have a tree for each project here, so it will look like
But right now all I can do with the lsits I have is use the full list of project anmes as the roots, and then the full list of devices as the child. SO I end up witha tree that has roots for each project, and then under each project root every single device is listed, and under each device every single channel is listed, instead of the root project 1 only having the devices and channels that belong to it, etc
I have been experimenting with for loops and such to get this doing what I need, but not much luck.
Any suggestions on how to handle this?>
True wisdom is in knowing you know nothing - Socrates
Thats funny, I was talking to someone else today and they said the exact same thing and told me to look into the TreeNode type.
If you care to elaborate any please do, I mean i know how to get these values into a list, but Im still a bit mystified by lists.
Is it just a way to store a bunch of string values? Or is there a cooresponding key or type with each item in the list? In other words if I take all the name values from my xml, does the list know that each of these strings it is holding are "names"? And if I then add all the IDs to this same list, does the list know it is holding to types of values? This seems like it would have to be so if I am to use lists to separate the values.
if you can recommend any tutorials or somethign I should look into please do
I know have a better example of what my projects xml looks like:
So as you can see, instead of device Names I am only going to have device Ids under the <devices> tag. This further complicates matters because I am not going to have a project as the root and the device ID under each project root. I know have to figure out a way to Use the project name as the roots, then look at the device IDs found under each project, then go to another xml that holds the deviceId and deviceName together, pull out the correct deviceName by the deviceId that is found in the projects xml, and use that as the node under the projectName root.
And I cant even get the project to have the deviceId as its chld, much less adding in those extra steps!
I have no idea what to do here, I do not even know where to start
you know I may already be part way there without reaizing it. I have four classes pertaining t these two entities. For projects, I have a project class that has all the usual stuff, project name, project Id, etc. ANd then I also have a projectCollection class, that looks like this:
So is this a start? Or will I not even be using this projectCollection class? I also have these two classes for devices btw.
Right now I am able to use for loops, something like for (MeasurementProject measurementProject : measurementProjectCollection.getMeasurementProjects())
which translates to "for every project in the project Collection" right?
So is this on the way to what i am needing.. Right now, when I load the list up with project Names, it is done this way:
So that goes through every project in the collection, grabs the name, and adds it to the projectNameList.
SO am I part way there without realizing it or does this not pertain?
edit - I gotta think this means it is close to what i need. Maybe I just need to use TreeNode here. something like for every project in the collection, TreeNode.addroot(projectname) and TreeNode.addchild(deviceName), or something like that. I dont know this is very abstract to me still, can omeone help me clear this up more please?
This problem is the last one in this project I need to overcome to be able to fully complete this thing
edit - maybe does someone have an example of this being done using xml as the data source? not an actual xml file, but xml that is retrieved as a Stream. SO something like Stream x = method.getResponseBodyAsStream (which returns the xml as a stream)
subject: need suggestions on how to deal with data iteration problems