How to get “xmlns:XXX” attribute if set setNamespaceAware(true) in SAX?

我只是一个虾纸丫 提交于 2019-12-04 07:12:39

When your XML parser is XML Namespace aware, then you should not need access to those properties, as they only define the short names for namespaces used in your XML.

In that case you always refer to the name spaces using their full name (e.g. http://schemas.xmlsoap.org/wsdl/) and can ignore what short name they are aliased to in the XML (e.g. wsdl).

The fact that SAX doesn't provide those values is documented on the Attributes class:

It will [...] not contain attributes used as Namespace declarations (xmlns*) unless the http://xml.org/sax/features/namespace-prefixes feature is set to true (it is false by default).

So using saxfac.setFeature("http://xml.org/sax/features/namespace-prefixes", true) should help you get to those values.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!