简体   繁体   English

具有名称空间前缀的TagSoup属性

[英]TagSoup attributes with namespace prefix

For parsing an xml response using TagSoup I am extending the DefaultHandler, now I have the problem that it ignores an attribute with a qualified name in the method; 为了使用TagSoup解析xml响应,我扩展了DefaultHandler,现在我遇到的问题是,它忽略了方法中带有限定名称的属性。

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

The element looks as follows; 该元素如下所示;

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

when it gets to the startElement method for this element, the atts parameter has no attributes in it. 当到达该元素的startElement方法时,atts参数中没有属性。 Does anyone know how to fix this without adjusting the xml? 有谁知道如何在不调整xml的情况下解决此问题?

Edit I tried using the setFeature method for the feature; 编辑我试过使用setFeature方法的功能;

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

But without any result 但没有任何结果

I fixed it by stopping to use TagSoup, and resolved to the standard Android SAXParser. 我停止使用TagSoup来解决此问题,并解析为标准的Android SAXParser。 Then I changed feature settings as follows; 然后,我如下更改功能设置;

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM