我想提取hotel内容之前的xml片段,请问怎样才能够实现?
<?xml version= "1.0 " ?>
- <soap:Envelope xmlns:soap= "http://schemas.xmlsoap.org/soap/envelope/ " xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance " xmlns:xsd= "http://www.w3.org/2001/XMLSchema ">
- <soap:Body>
- <SearchHotelsResponse xmlns= "http://tourico.com/webservices/ ">
- <SearchHotelsResult>
- <xs:schema id= "TWS_HotelList " targetNamespace= "http://tourico.com/webservices/TWS_HotelList.xsd " xmlns:mstns= "http://tourico.com/webservices/TWS_HotelList.xsd " xmlns= "http://tourico.com/webservices/TWS_HotelList.xsd " xmlns:xs= "http://www.w3.org/2001/XMLSchema " xmlns:msdata= "urn:schemas-microsoft-com:xml-msdata " attributeFormDefault= "qualified " elementFormDefault= "qualified ">
+ <xs:element name= "TWS_HotelList " msdata:IsDataSet= "true ">
- <xs:complexType>
- <xs:choice maxOccurs= "unbounded ">
- <xs:element name= "Hotel ">
- <xs:complexType>
- <xs:sequence>
- <xs:element name= "RoomType " minOccurs= "0 " maxOccurs= "unbounded ">
- <xs:complexType>
- <xs:sequence>
- <xs:element name= "Avail " minOccurs= "0 " maxOccurs= "unbounded ">
- <xs:complexType>
<xs:attribute name= "offset " form= "unqualified " type= "xs:byte " use= "required " />
<xs:attribute name= "status " form= "unqualified " type= "xs:boolean " use= "required " />
</xs:complexType>
</xs:element>
- <xs:element name= "Discount " minOccurs= "0 " maxOccurs= "unbounded ">
- <xs:complexType>
<xs:attribute name= "from " form= "unqualified " type= "xs:dateTime " use= "required " />
<xs:attribute name= "to " form= "unqualified " type= "xs:dateTime " use= "required " />
<xs:attribute name= "pay " form= "unqualified " type= "xs:int " use= "required " />
<xs:attribute name= "stay " form= "unqualified " type= "xs:int " use= "required " />
</xs:complexType>
</xs:element>
- <xs:element name= "Occup " minOccurs= "0 " maxOccurs= "unbounded ">
- <xs:complexType>
- <xs:sequence>
- <xs:element name= "Supp " minOccurs= "0 " maxOccurs= "unbounded ">
- <xs:complexType>
<xs:attribute name= "supId " form= "unqualified " type= "xs:int " />
<xs:attribute name= "name " form= "unqualified " type= "xs:string " use= "required " />
<xs:attribute name= "price " form= "unqualified " type= "xs:double " use= "required " />
</xs:complexType>
</xs:element>
- <xs:element name= "Board " minOccurs= "0 " maxOccurs= "unbounded ">
- <xs:complexType>
<xs:attribute name= "bbId " form= "unqualified " type= "xs:int " />
<xs:attribute name= "name " form= "unqualified " type= "xs:string " use= "required " />
<xs:attribute name= "price " form= "unqualified " type= "xs:double " use= "required " />
<xs:attribute name= "default " form= "unqualified " type= "xs:boolean " default= "false " />
</xs:complexType>
</xs:element>
- <xs:element name= "Room " minOccurs= "0 " maxOccurs= "unbounded ">
- <xs:complexType>
- <xs:sequence>
- <xs:element name= "Child " minOccurs= "0 " maxOccurs= "unbounded ">
- <xs:complexType>
<xs:attribute name= "age " form= "unqualified " type= "xs:int " />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name= "seqNum " form= "unqualified " type= "xs:int " use= "required " />
<xs:attribute name= "adultNum " form= "unqualified " type= "xs:int " use= "required " />
<xs:attribute name= "childNum " form= "unqualified " type= "xs:int " />
</xs:complexType>
</xs:element>
- <xs:element name= "Price " minOccurs= "0 " maxOccurs= "unbounded ">
- <xs:complexType>
<xs:attribute name= "offset " form= "unqualified " type= "xs:int " use= "required " />
<xs:attribute name= "value " form= "unqualified " type= "xs:double " use= "required " />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name= "occupId " form= "unqualified " type= "xs:string " use= "required " />
<xs:attribute name= "maxAdult " form= "unqualified " type= "xs:int " use= "required " />
<xs:attribute name= "maxChild " form= "unqualified " type= "xs:int " use= "required " />
<xs:attribute name= "price " form= "unqualified " type= "xs:double " use= "required " />
<xs:attribute name= "tax " form= "unqualified " type= "xs:double " use= "required " />
<xs:attribute name= "dblBed " form= "unqualified " type= "xs:boolean " />
<xs:attribute name= "avrNightPrice " form= "unqualified " type= "xs:double " use= "required " />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name= "productId " form= "unqualified " type= "xs:string " use= "required " />
<xs:attribute name= "name " form= "unqualified " type= "xs:string " use= "required " />
<xs:attribute name= "nights " form= "unqualified " type= "xs:byte " use= "required " />
<xs:attribute name= "startDate " form= "unqualified " type= "xs:dateTime " use= "required " />
<xs:attribute name= "isAvailable " form= "unqualified " type= "xs:boolean " />
<xs:attribute name= "roomId " form= "unqualified " type= "xs:int " />
<xs:attribute name= "hotelRoomTypeId " form= "unqualified " type= "xs:int " />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name= "hotelId " form= "unqualified " type= "xs:int " use= "required " />
<xs:attribute name= "provider " form= "unqualified " type= "xs:string " use= "required " />
<xs:attribute name= "name " form= "unqualified " type= "xs:string " use= "required " />
<xs:attribute name= "address " form= "unqualified " type= "xs:string " />
<xs:attribute name= "category " form= "unqualified " type= "xs:string " />
<xs:attribute name= "bestVal " form= "unqualified " type= "xs:byte " />
<xs:attribute name= "thumb " form= "unqualified " type= "xs:string " />
<xs:attribute name= "starsLevel " form= "unqualified " type= "xs:double " />
<xs:attribute name= "minAverPrice " form= "unqualified " type= "xs:double " use= "required " />
<xs:attribute name= "desc " form= "unqualified " type= "xs:string " use= "required " />
<xs:attribute name= "location " form= "unqualified " type= "xs:string " use= "required " />
<xs:attribute name= "currency " form= "unqualified " type= "xs:string " />
<xs:attribute name= "brandId " form= "unqualified " type= "xs:int " />
<xs:attribute name= "brandName " form= "unqualified " type= "xs:string " />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
- <TWS_HotelList xmlns= "http://tourico.com/webservices/TWS_HotelList.xsd ">
[解决办法]
你想取 <xs:schema> 的内容是吗?
在什么开发环境里取?
最简便的,字符串处理,正则表达式