hello guys,
i've got one more problem using proxml.
I have a xml file saving 3 values for each element inside. Now when executing my Processing script I want to go through all of the xm-elements and change all those whose 3rd value is 0 instead of 1.
<?xml version="1.0" encoding="ISO-8859-1"?>
<positions>
<type>
<dataType v1="200" v2="12" v3="1"/>
</type>
<type>
<dataType v1="150" v2="12" v3="1"/>
</type>
<type>
<dataType v1="100" v2="12" v3="0"/>
</type>
</positions>
So in my example above I have to write a script that changes in the third element the last value from 0 to 1.
I don't know how to go through the xml data and just concern about those rows in which the third value is 0 instead of 1. I then want to change it from 0 to 1 and save it.
Next time I execute the script I do the same thing. I only want to change the first element I can find in which there is a 0 instead of 1 at value "v3".
Can you guys give me a hint how to do so?
I tried to start it this way, maybe you can come up with some extensions on this code?
Thanks a lot!
Code: proxml.XMLElement[] allValues = element.getChildren();
for (int i = 0; i < allValues.length;i++)
{
proxml.XMLElement Value = allValues[i];
proxml.XMLElement param = Value.getChild(0);
//println(param.getName());
if (!param.getName().equals("dataType"))
continue; // Ignore unknown child
value1 = param.getIntAttribute ("v1");
value2 = param.getIntAttribute("v2");
value3 = param.getIntAttribute("v3");
if (value3 == 0) {
// i think i have to add a new attribute at this place?!
}
}