sql server - T-SQL XQuery Node Value Path not Matching -
while works retrieving local-name(.)
node names demonstrated here can't table resume first name , resume last name each job candidate.
use adventureworks2012; xmlnamespaces( 'http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/resume' ns) select t.rows.value('(ns:name.first)[1]', 'nvarchar(100)') firstname, t.rows.value('(ns:name.last)[1]', 'nvarchar(100)') lastname humanresources.jobcandidate cross apply resume.nodes('//ns:name/*') t(rows);
the error message lists nodes in context, including appears targeted node.
xquery [humanresources.jobcandidate.resume.value()]: there no element named "{http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/resume}:name.first" in type "element(ns{http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/resume}:name.prefix,xs:string) | element(ns{http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/resume}:name.first,xs:string)
...
element(ns{http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/resume}:name.last,xs:string) | element(ns{http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/resume}:name.suffix,xs:string)".
is problem element
level down?
problem context level deep. fixed removing /*
nodes
path.
with xmlnamespaces( 'http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/resume' ns) select t.rows.value('(ns:name.first)[1]', 'nvarchar(100)') firstname, t.rows.value('(ns:name.last)[1]', 'nvarchar(100)') lastname humanresources.jobcandidate cross apply resume.nodes('//ns:name/*') t(rows);
Comments
Post a Comment