I'm using java w3c DOM library for parsing XML document.
part of the XML document looks like :
<pin direction="output" id="out0" index="0" type="org.opencv.core.Mat">
<property class="java.lang.String" name="tooltip"><![CDATA[, output image]]></property>
<property class="java.util.UUID" name="uuid"><![CDATA[4a729579-e4f4-4e5c-8522-025701e19039]]></property>
<property class="java.lang.Class" name="blockClass"><![CDATA[class org.obbb.model.Pin]]></property>
</pin>
<pin direction="output" id="out1" index="1" type="java.lang.String">
<property class="java.lang.String" name="tooltip"><![CDATA[, filename]]></property>
<property class="java.util.UUID" name="uuid"><![CDATA[88f616b6-4baf-423d-b2af-8df48ef25184]]></property>
<property class="java.lang.Class" name="blockClass"><![CDATA[class org.obbb.model.Pin]]></property>
</pin>
<pin direction="output" id="out2" index="2" type="java.lang.String">
<property class="java.lang.String" name="tooltip"><![CDATA[, file path]]></property>
<property class="java.util.UUID" name="uuid"><![CDATA[1ca31982-6dea-4f48-8781-7f8194ba874a]]></property>
<property class="java.lang.Class" name="blockClass"><![CDATA[class org.obbb.model.Pin]]></property>
</pin>
In this structure I need to parse the hash codes:
4a729579-e4f4-4e5c-8522-025701e19039
88f616b6-4baf-423d-b2af-8df48ef25184
1ca31982-6dea-4f48-8781-7f8194ba874a
My code for that is :
for (int i = 0; i < pinsLength; i++) {
Node pin = pins.item(i);
if ( pin.getNodeType() == Node.ELEMENT_NODE ) {
Element pinElement = (Element)pin;
String uuid = pinElement.getChildNodes().item(1).getTextContent();
}
}
Will the hash code will always be saved in uuid variable
since it's always second property element in the XML file?