我能夠爲有效字符做xml解析,但是當我從我的URL字符串中傳遞無效字符時,沒有找到結果,但是當我通過該web服務時從我的瀏覽器然後結果found.so我認爲問題解析爲無效字符做薩克斯xml解析,所以如何克服這個問題,意味着如何處理無效字符意味着在url http://www.arteonline.mobi/iphone/output.php?st=&ct=&type=Clínicas%20y%20Talleres&neigh=
對於類型屬性我通過類型=Clínicas其中第三個字符不是英文字母,它在西班牙文,所以如何處理這個西班牙文如何處理xml解析無效字符在URL中獲取結果
字符。我的代碼是下面....
@Override
protected Boolean doInBackground(String... args) {
try{
try {
String temp = "http://www.arteonline.mobi/iphone/output.php?st="+filter.stateselected+"&ct="+filter.cityselected+"&type="+filter.typeselected+"&neigh="+filter.neighbourselected+"";
//String temp = "http://www.arteonline.mobi/iphone/output.php?st=&ct=&type=Clínicas%20y%20Talleres&neigh=";
temp = temp.replaceAll(" " ,"%20");
// temp= temp.replaceAll("í" ,"í");
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
Log.i("temp url..",temp.trim().toString());
URL sourceUrl = new URL(temp.trim());
XMLHandlerfiltersearch myXMLHandler = new XMLHandlerfiltersearch();
xr.setContentHandler(myXMLHandler);
xr.parse(new InputSource(sourceUrl.openStream()));
}
catch (Exception e) {
System.out.println("XML Pasing Excpetion = " + e);
}
我在URL替換空間,如果任何通過使用臨時= temp.replaceAll(」 「」 %20" );
,但我不能與西班牙字符買賣類型的屬性在我的Web服務URL .PLS幫助.....
還檢查類型= GALERIAS當從Web服務URL通。在這種6 charaacter無效..
你試過URL.encode使用UTF-8 – ingsaurabh
我寫 在我的.xml文件 – shyam
有你看着使用'UrlQuerySanitizer' http://developer.android.com/reference/android/net/UrlQuerySanitizer.html? – Seph