XPATH query for not equal to
400053Jun 19 2008 — edited Jun 23 2008I have the following XML stored in XMLType column in table
<ContactInfo>
<Phones>
<Phone PhoneLocationType="1" PhoneNumber="1-800-468-3571" PhoneTechType="1" PhoneUseType="6"/>
<Phone PhoneLocationType="3" PhoneNumber="1-800-228-7697" PhoneTechType="1" PhoneUseType="6"/>
<Phone AreaCityCode="202" CountryAccessCode="1" PhoneLocationType="4" PhoneNumber="776-9182" PhoneTechType="3"/>
<Phone AreaCityCode="202" CountryAccessCode="1" PhoneLocationType="5" PhoneNumber="466-9083" PhoneTechType="3"/>
<Phone AreaCityCode="202" CountryAccessCode="1" PhoneLocationType="4" PhoneNumber="888-8888" PhoneTechType="3" PhoneUseType="7"/>
</Phones>
</ContactInfo>
I can query the last phone number that has attributes PhoneLocationType="4", PhoneTechType="3" and PhoneUseType="7" using
the following query
SELECT extractvalue(HOTEL_XML, 'HotelDescriptiveContent/ContactInfos/ContactInfo[@ContactProfileType=''Property Info'']/Phones/Phone[@PhoneLocationType=4 and @PhoneUseType=7 and @PhoneTechType=3]/@PhoneNumber')
FROM si_hotel_content
where marsha_code='XXXX';
However to retrieve the phone number that has attributes PhoneLocationType="4", PhoneTechType="3" but not PhoneUseType="7" (see the 3rd phone in the XML), I could not pass the correct XPath? For example, I tried
SELECT extractvalue(HOTEL_XML, 'HotelDescriptiveContent/ContactInfos/ContactInfo[@ContactProfileType=''Property Info'']/Phones/Phone[@PhoneLocationType=4 and @PhoneUseType !=7 and @PhoneTechType=3]/@PhoneNumber')
FROM si_hotel_content
where marsha_code='XXXX';
and it failed?
Is there any way I can select elements / attribute values by using != operator in Xpath? Or is there another way to achieve this? Any thoughts ?