Good Afternoon Experts,
I'm using the xml data type for the first time , and I don't see where is the error in the following example:
-------------
declare @myDoc xml
declare @ProdID varchar(20)
set @myDoc = '<processRequest xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="
http://www.w3.org/2001/XMLSchema" source="RequestBusinessSer
viceBookin
g" destination="" propertyKey="10157" name="" GUID="5-5" vendorID="eS">
<input xmlns="
http://www.yourdomain.com">
<Bookings>
<Booking>
<BookingDetails key="96363.10149" name="" secondaryName="" abbreviation="" bookingTypeKey="2.10149.2"
bookingType="GRP" arriveDate="2010-11-05" departDate="2010-11-05" status="prospect" decisonDate="2010-10-30" cutoffDate="2010-10-16" blockCode="" compRooms="0" commissionPer="0" statusDate="2010-10-16" createDate="2010-10-16" pickupComplete="false">
<BookedBy key="280547.10149" name="Jessica Alba" initials="JFO" email="jalba@yourdomain.co
m" />
<MarketSegment key="2.10149" name="Social" abrv="SOCL" />
</BookingDetails>
</Booking>
</Bookings>
</input>
</processRequest>'
set @ProdID = @myDoc.value('(/processReq
uest/input
/Bookings/
Booking/Bo
okingDetai
ls/@bookin
gType)[1]'
, 'varchar(20)' )
select @ProdID
---------------------
the returned value is NULL
Thanks in advance for your help
It includes namespaces which can be tricky
Open in new window