我一直在搜索和閱讀SO,但沒有任何工作。我在XML Feed中遇到了字符問題。我將每個標籤的值保存在一個String中,但是當
發生時,它就停止。我只在標籤中獲得4-5個第一個單詞。在Java中解析XML時從字符串中刪除無效字符
那麼任何人都可以請幫我一個可以刪除它的方法嗎?或者,XML Feed中的標籤中的文本是否對於字符串來說太長?
謝謝!
示例代碼:
public void characters(char[] ch, int start, int length)
throws SAXException {
if (currentElement) {
currentValue = new String(ch, start, length);
currentElement = false;
}
}
public void endElement(String uri, String localName, String qName)
throws SAXException {
currentElement = false;
/** set value */
if (localName.equalsIgnoreCase("title"))
sitesList.setTitle(currentValue);
else if (localName.equalsIgnoreCase("id"))
sitesList.setId(currentValue);
else if(localName.equalsIgnoreCase("description"))
sitesList.setDescription(currentValue);
}
在描述標籤的文字是很長,但我的
字符之前僅獲得第五個字開始到來。
你可以顯示你的代碼的相關部分,以及你看到的是什麼樣的無效字符? –