In MS SQL 2005, is there a way to determine whether a specific node exists in an XML variable?
.... [parentNode]
........ [test1][/test1]
........ [test2][/test2]
........ [subNode]
............ [subTest1]123[/subTest1]
............ [subTest2]234[/subTest2]
........ [/subNode]
.... [/parentNode]
Once I load the XML into a variable, there will be instances when [subNode] may or may not exist. What's a straightforward method to detect whether [subNode] is present?
You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.
M$2 Answers
RETURN (SELECT @xmlData.exist('/parentNode/subNode'))
you might have to mess with the xpath query a little depending on the exact structure but I am pretty sure something like that will work.
http://msdn.microsoft.com/en-us/library/ms345117.aspx (under heading Example: Constraining XML Column)
You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.
M$http://www.15seconds.com/Issue/050803.htm
You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.
M$
Thanks; this issue actually I can use the features of 2005 with. The one related to the other question I can't because of time constraints; the time it'd take to change all the underlying code to use 2005's better XML functionality will have to wait until a deadline of mine has passed.