私はあなたの助けが必要です。
テキストを XML に変換しています (いくつかの追加属性を使用)
私のテキストは SPLINE(N, -1.151,1.002, -0.161,0.997, 0.840,-0.004, OUTLINED) です
次のようにJDOMを使用してXMLにする必要があります
<SPLINE n="3" x1="0.840" y1="-1.004" x2 ="-0.161" y2 ="0.997" x3 ="0.840" y3"-0.004" prim_style="OUTLINED" />
N が固定されている場合、単純に変換できます。上記の例では N= 3 であるため、3 つの x 座標と 3 つの y 座標があります。しかし、以下のように for ループを使用している場合、結果は例外ではありません。どんな助けでも素晴らしいでしょう
root.addContent(child);
document.setContent(root);
int i = Integer.parseInt(temp_token[2]);
int count = i * 2 + i + 4;
for (int j = 0; j <= count - 5; j = j + 3) {
String x = null;
String y = null;
Element SPLINE = new Element("SPLINE")
.setAttribute("n", temp_token[2])
.setAttribute("x", temp_token[j + 4])
.setAttribute("y", temp_token[j + 5])
.setAttribute("prim_style",
temp_token[count]);
child.addContent(SPLINE);
上記のコードから