2010-11-14 55 views
2

用於使用TagSoup解析xml響應我擴展了DefaultHandler,現在我遇到了一個問題,它忽略了方法中具有限定名稱的屬性;帶名稱空間前綴的TagSoup屬性

public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException 

該元素看起來如下;

<element xmlns:ns2="http://my.ns.url">{content}</element> 

當它到達此元素的startElement方法時,atts參數在其中沒有任何屬性。有誰知道如何解決這個問題,而無需調整XML?

編輯 我嘗試使用setFeature方法的功能;

http://xml.org/sax/features/namespace-prefixes 

,但沒有任何結果

+0

是不是TagSoup解析器的HTML?它生成SAX事件,但其主要目標是「從野外」解析HTML文件。 – 2010-11-15 07:53:34

回答

1

我固定它通過停止使用TagSoup,並決定標準Android的SAXParser。然後我改變了功能設置如下;

setFeature("http://xml.org/sax/features/namespaces", false);  
setFeature("http://xml.org/sax/features/namespace-prefixes", true); 
相關問題