Need Write Java Program Program Reads Xml File Text Similar Following Go Line Merge X Y Co Q43791223
I need to write a java program
Where the program reads an xml file that has a text similar tothe following
</Compartment>
<Compartment Name=”” Top1=”true” AlternateName=”NONE”>
<Level Level=”level101″>
<Poly xCoordinate=”1781.0; 1788.0; 1744.0; 1240.0; 1640.0;1281.0″ yCoordinate=”308.0; 318.0; 327.0; 223.0; 408.0;358.0″></Poly></Level>
</Compartment>
</Compartment>
<Compartment Name=”” Top2=”true” AlternateName=”NONE”>
<Level Level=”level101″>
<Poly xCoordinate=”1541.0; 1748.0; 1744.0; 1140.0; 1240.0;1381.0″ yCoordinate=”358.0; 313.0; 327.0; 223.0; 403.0;338.0″></Poly></Level>
</Compartment>
</Compartment>
<Compartment Name=”” Top3=”true” AlternateName=”NONE”>
<Level Level=”level101″>
<Poly xCoordinate=”112.0; 1188.0; 1444.0; 1540.0; 1620.0;1271.0″ yCoordinate=”318.0; 338.0; 427.0; 123.0; 908.0;328.0″></Poly></Level>
</Compartment>
it will go through each line and merge x and y coordinatestogether with a “,” in between in a single line.
so for example:
after reading the file as an input the system output will be
XandY= 1781.0,308.0,1788.0,318.0, 1744.0, 327.0, 1240.0,223.0,1640.0, 408.0, 1281.0, 358.0
XandY= this will be top2 compatment coordinates
XandY= this will be top3 compatment coordinates
Thank you.
Expert Answer
Answer to I need to write a java program Where the program reads an xml file that has a text similar to the following it will go t…
OR