这里是我的代码:如果在SAX中设置setNamespaceAware(true),如何获得“xmlns:XXX”属性?
path = wsdlPath;
SAXParserFactory saxfac = SAXParserFactory.newInstance();
saxfac.setNamespaceAware(true);
saxfac.setXIncludeAware(true);
saxfac.setValidating(false);
SAXParser saxParser = saxfac.newSAXParser();
saxParser.parse(wsdlPath, this);
设置setNamespaceAware=true
后,我无法在方法public void startElement(String uri, String localName, String qName, Attributes attributes)
的参数attributes
的xmlns:XXX
属性。
以下节点:
<definitions name="Service1"
targetNamespace="http://www.test.com/service"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:tns="http://www.test.com/">
我只是得到name
和targetNamespace
属性。 xmlns
,xmlns:wsdl
,xmlns:mime
,xmlns:http
和xmlns:tns
在attributes
参数中。但他们无法访问。
有什么方法可以使用setNamespaceAware=true
并获得节点的所有属性?
它的作品!许多许多感谢你! – DeepNightTwo 2011-03-24 09:24:23
我尝试使用这个建议,发现我也必须做以下操作:'saxfac.setFeature(“http://xml.org/sax/features/namespaces”,false);' – 2011-04-06 17:05:57