I have an output and I convert it to XML but the XML appears with some tags out of place or miss-written.
Here's the Ilog output:
Y = [[[7.5
7.5 7.5 7.5 7.5 7.5 7.5 7.5 7.5 7.5 7.5 7.5 7.5 7.5 7.5]
[9.6 9.6 9.6 9.6 9.6 9.6 9.6 9.6 9.6 9.6 9.6 9.6 9.6 9.6 9.6]
[8.8889 8.8889 8.8889 8.8889 8.8889 8.8889 8.8889 8.8889 8.8889
8.8889 8.8889 8.8889 8.8889 8.8889 8.8889]
[8.2759 8.2759 8.2759 8.2759 8.2759 8.2759 8.2759 8.2759 8.2759
8.2759 8.2759 8.2759 8.2759 8.2759 8.2759]]
[[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]];
X = [[[7.5 7.5 7.5 7.5 7.5 7.5 7.5 7.5 7.5 7.5 7.5 7.5 7.5 7.5 7.5]
[9.6 9.6 9.6 9.6 9.6 9.6 9.6 9.6 9.6 9.6 9.6 9.6 9.6 9.6 9.6]
[8.8889 8.8889 8.8889 8.8889 8.8889 8.8889 8.8889 8.8889 8.8889
8.8889 8.8889 8.8889 8.8889 8.8889 8.8889]
[8.2759 8.2759 8.2759 8.2759 8.2759 8.2759 8.2759 8.2759 8.2759
8.2759 8.2759 8.2759 8.2759 8.2759 8.2759]]
[[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]];
The XML output:
<?xml version="1.0" encoding="UTF-8"?>
<Solutions>
<output_quantity>
<Y/> <--- one of the problem's
<Y>7.5<Y/>
<Y>7.5</Y><--- the other problem
<Y>7.5</Y>
<Y>7.5</Y>
<Y>7.5</Y>
<Y>7.5</Y>
<Y>7.5</Y>
<Y>7.5</Y>
<Y>7.5</Y>
<Y>7.5</Y>
<Y>7.5</Y>
<Y>7.5</Y>
<Y>7.5</Y>
<Y>7.5</Y>
<Y>7.5</Y>
</output_quantity>
<output_quantity>
<Y/>
<Y>9.6</Y>
<Y>9.6</Y>
<Y>9.6</Y>
<Y>9.6</Y>
<Y>9.6</Y>
Here is my code:
public void process(String s) throws SAXException {
String[] elements = s.split("");
int flag = 0, flag2 = 0;
atts.clear();
if (s.contains("Y = ") || Y == 1) {
if (Y == 0) {
Y++;
th.startElement("", "", "Solutions", atts);
th.startElement("", "", "output_quantity", atts);
}
for (int i = 0; i < elements.length; i++) {
if (elements[i].equals(" ") && flag == 1 && flag2 == 1
|| elements[i].equals("]")) {
flag = 0;
if (flag2 == 1) {
th.endElement("", "", "Y");
if (elements[i].equals("]")) {
th.endElement("", "", "output_quantity");
th.startElement("", "", "output_quantity", atts);
}
}
flag2 = 0;
}
if (!elements[i].equals("[") && !elements[i].equals("Y")
&& !elements[i].equals("=") && !elements[i].equals(" ")
&& !elements[i].equals("]") && !elements[i].equals(";")) {
if (flag == 0)
th.startElement("", "", "Y", atts);
// Y++;
flag = 1;
flag2 = 1;
th.characters(elements[i].toCharArray(), 0,
elements[i].length());
// System.out.println("Information " + elements[i]);
}
}
if (s.contains("]]];")) {
// Y++;
th.endElement("", "", "output_quantity");
// th.endElement("", "", "Solutions");
}
}
Is there a way of removing those tags and correct the misplaced "/"? Regards