renu
renu

Reputation: 31

How to parse a WSDL file to extract the contents of a particular node

Here is a part of my wsdl file:

<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
- <s:element name="BinaryConversion">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="Binary" type="s:string" /> 
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:element name="BinaryConversionResponse">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="BinaryConversionResult" type="s:string" /> 
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:element name="Qos">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="1" maxOccurs="1" name="Availabilty_10" type="s:int" /> 
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:element name="QosResponse">
  <s:complexType /> 
  </s:element>
- <s:element name="GetQosParameters">
  <s:complexType /> 
  </s:element>
- <s:element name="GetQosParametersResponse">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="1" maxOccurs="1" name="GetQosParametersResult" type="tns:QoSParameters" /> 
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:complexType name="QoSParameters">
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="Availability" type="s:string" /> 
  <s:element minOccurs="0" maxOccurs="1" name="Accuracy" type="s:string" /> 
  <s:element minOccurs="0" maxOccurs="1" name="Accessibility" type="s:string" /> 
  <s:element minOccurs="0" maxOccurs="1" name="Latency" type="s:string" /> 
  <s:element minOccurs="0" maxOccurs="1" name="Reliability" type="s:string" /> 
  </s:sequence>
  </s:complexType>
  </s:schema>
  </wsdl:types>

Now I want to extract the names Availability ,Accuracy,Latency etc.How do I do this. I used Document Builder to parse but I am only able to extract wsdl:operations and not wsdl:types

Upvotes: 2

Views: 5992

Answers (1)

paulsm4
paulsm4

Reputation: 121649

Here's a good Java/XML tutorial (one of many):

Scroll down to the part where he talks about XPath. That's the syntax you need to fetch a subnode (e.g. "QoSParameters") and everything in it (e.g. "Availability", "Accuracy", etc).

Upvotes: 2

Related Questions