带有命名空间前缀的 TagSoup 属性

发布于 2024-10-02 08:13:39 字数 553 浏览 0 评论 0原文

为了使用 TagSoup 解析 xml 响应,我扩展了 DefaultHandler,现在我遇到的问题是它忽略了方法中具有限定名称的属性;

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

但没有任何结果

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;

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. Does anyone know how to fix this without adjusting the xml?

Edit
I tried using the setFeature method for the feature;

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

But without any result

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拒绝两难 2024-10-09 08:13:39

我通过停止使用 TagSoup 修复了这个问题,并解决了标准 Android SAXParser。然后我更改了功能设置,如下所示;

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

I fixed it by stopping to use TagSoup, and resolved to the standard 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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文