私はブラックベリーのxmlで作業しています。 私は現在xml文字列を扱っています。値の1つは別のxml文字列です。 問題は、他の値はきれいに抽出されていますが、xml値は正しくないことです。 "<"のみがノードから抽出されています。ブラックベリーの別のXMLストリングから埋め込みXMLを抽出し、ブラックベリーでXMLをデコードする
同じ、通常のjavaで動作しているようです。
Javaプロジェクトで:
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
connection.setRequestProperty("Content-Length", "" + Integer.toString(resultText.getBytes().length));
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
wheras、ブラックベリーは、使用しています:私は見ることができ 唯一の違いは、リクエストが見た方法です
http.setRequestMethod(HttpConnection.POST);
http.setRequestProperty("User-Agent","Blackberry 8320/4.2.2 Profile/MIDP-2.0 Configuration/CLDC-1.1");
http.setRequestProperty("x-rim-transcode-content", "none");
http.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
http.setRequestProperty("Content-Length","" + Integer.toString(resultText.getBytes().length));
、次のコードは、 Webサービスからの応答を取得するために使用されます::
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
StringBuffer response = new StringBuffer();
while ((line = rd.readLine()) != null) {
response.append(line);
response.append('\r');
}
rd.close();
in BB
InputStream inStream = http.openInputStream();
// Get the length and process the data
int len = (int) http.getLength();
if (len > 0)
{
int actual = 0;
int bytesread = 0;
byte[] data = new byte[len];
while ((bytesread != len) && (actual != -1)) {
actual = inStream.read(data, bytesread, len - bytesread);
bytesread += actual;
}
String recd = new String(data, "UTF-8");
responseData = recd;
この変更以外の違いはありません。埋め込まれたXMLがJavaプロジェクトで完全に抽出されたが、BBプロジェクトは、唯一の「<」:-(
任意のヘルプははるかに高く評価されるだろう。
を解析されているxmlファイルはここにある取り出します:(いません完全なものを提供する埋め込まれたXML内の1つの値ではなく、すべてを削除した
response:::::<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas .xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.o rg/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://sche mas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:glwsdl"><SOAP-ENV:Body><return xsi:type="SOAP-ENC:Arr ay" SOAP-ENC:arrayType="tns:CrosswordItem[1]"><item xsi:type="tns:CrosswordItem"><Date xsi:type="xsd :string">2012-01-04</Date><Crossword xsi:type="xsd:stri ng"><?xml version="1.0" encoding="UTF-8"?>
<crossword size="7">
<grid>
<cell position="5_6" value="&#xAB0;&#xABE;"/>
<cell position="6_6" value="&#xAA8;"/>
</grid>
<horizontalkeys>
<key number="19" position="3_6" length="4" answer="&#xA9 C;&#xABE;&#xAAB;&#xAB0;&#xABE;&#xAA8;" question="&#xA95;&#xAC7 ;&#xAB8;&#xAB0;"/>
</horizontalkeys>
<verticalkeys>
<key number="17" position="6_5" length="2" answer="&#xAA E;&#xABE;&#xAA8;" question="&#xA86;&#xAAC;&#xAB0;&#xAC2;, &#xA AA;&#xACD;&#xAB0;&#xAA4;&#xABF;&#xA B7;&#xACD;&#xAA0;&#xABE;"/>
</verticalkeys>
</crossword>
</Crossword><Gridsize xsi:type="xsd:string">7</Gridsize><Id xsi:type="xsd:string">63</Id></item></re turn></SOAP-ENV:Body></SOAP-ENV:Envelope>
編集:。。 私は部分的に問題を解決した: 使用:
xmlEmbeddedData = xmlData.substring(xmlData.indexOf("<?xml version="1.0"encoding="UTF-8"?>"), xmlData.indexOf("</Crossword>"));
を
は、私は今containes、私は1つの問題は、私が解析する必要がXML文字列を、別の文字列に必要なものを抽出するための管理:「&グラムトン。 "for>、" &1t "; <と" & "の場合; &アンペア;?」...スペースなし...
私は、文字列をデコードし、私が解析できるXML文字列を取り戻す必要がある 誰かが助けることができる
最後のポイント:埋め込まれたXML文字列がCDATAです。 – s5v