XML Parsing

Eugene Prokopiev <[email protected]>
Newsgroups gmane.comp.mozilla.devel.xml
Organization Another Netscape Collabra Server User
Message-ID <[email protected]>
Hi,

I have file people.wsdl:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions 
targetNamespace="http://localhost:8080/wsapp/services/PeopleService" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
   <wsdl:portType name="PeopleService">
     <wsdl:operation name="add" parameterOrder="name sex age"/>
     <wsdl:operation name="getList"/>
     <wsdl:operation name="del" parameterOrder="id"/>
   </wsdl:portType>
</wsdl:definitions>

I need to get all wsdl:portType and all wsdl:operation for every 
wsdl:portType.

Code:

var doc = 
document.implementation.createDocument("http://schemas.xmlsoap.org/wsdl/","wsdl",null);
doc.load("people.wsdl");
var definitions = doc.getElementsByTagName("definitions");
alert(definitions[0].getAttribute("targetNamespace"));
var portType = doc.getElementsByTagName("portType");
alert(portType[0].getAttribute("name"));
var operation = doc.getElementsByTagName("operation");
for(var i=0; i<portType.length; i++) {
    alert(operation[i].getAttribute("name"));
}

On line 4 I got error:

Error: definitions[0] has no properties

What's wrong?

Can I use XPath expressions like this:

getElementsByTagName("/definitions/portType/operation[0]") ?

--
Thanks,
Eugene Prokopiev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.