SAX 구문 분석기를 사용할 때 "노드 내용에"이 있으면 구문 분석이 실패합니다. 어떻게 해결할 수 있습니까? 모든 "문자를 변환 하시겠습니까? 핸들러가 구문 분석 할 때 그 노드가 여러 문자 배열로 도살됩니다Android API 1.5의 SAX 파서 (javax.xml.parsers.SAXParser)로 따옴표를 구문 분석하는 데 문제가 있습니다.
<node>characters in node containing "quotes"</node>
:
즉, 언제 내가 노드에서 인용문이. 이것은 정상적인 행동입니까? 따옴표로 인해 문제가 발생하는 이유는 무엇입니까?import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
...
HttpGet httpget = new HttpGet(GATEWAY_URL + "/"+ question.getId());
httpget.setHeader("User-Agent", PayloadService.userAgent);
httpget.setHeader("Content-Type", "application/xml");
HttpResponse response = PayloadService.getHttpclient().execute(httpget);
HttpEntity entity = response.getEntity();
if(entity != null)
{
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
ConvoHandler convoHandler = new ConvoHandler();
xr.setContentHandler(convoHandler);
xr.parse(new InputSource(entity.getContent()));
entity.consumeContent();
messageList = convoHandler.getMessageList();
}
모든 조합에서 "sax"및 "parser"태그를 반복하는 대신 어떤 언어, 플랫폼 및 특정 파서를 말하면 어떻습니까? – skaffman
원래이 질문을 게시 할 때 서둘러서 죄송합니다. 그 후 메서드 및 메서드에 전달 된 문자 배열을 가져 오는 처리기 코드를 빼고 코드와 플랫폼을 사용하여 업데이트했습니다. public void characters (char ch [], int start, int length) { .. . else if (in_text) { \t \t \t \t message.setText (new String (ch, start, length)); \t \t \t} 인용 함유 노드의 경우 \t ... } 는 문자 배열이 잘못 동일한 노드에 대한 복수의 문자 배열로 잘게된다. – JohnRock