How to select value from strongly typed XML

Table Name: TableHasXML
has Column: XML_Column xml(XMLCollectionSchema)

XML data is similar to:
[root xmlns="" ....]
[row ]
[column1]Things We Love to Hate[/column1]
[column1]Pinay Programmer[/column1]

(yes, I know that was sloppy but blogger wouldn't let me just copy-paste my actual schema. Blogger treats any greater than/less than signs as HTML tags)

XML_Column.query('declare default element namespace "";
data(/root/row[Column1="Things We Love to Hate"]/Column2)')

Result =

If your XML column or variable doesn't have a namespace then leave out the namespace declaration as well:
XML_Column.query('data(/root/row[Column1="Things We Love to Hate"]/Column2)') FROM TableHasXML

No comments: