Next Question
RSS
Wait, I thought you were doing it in 2000? Anyway, something like this:
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.
Source(s):
http://msdn.microsoft.com/en-us/library/ms345117.aspx (under heading Example: Constraining XML Column)
Permalink | Report
darth cont...
http://www.15seconds.com/Issue/050803.htm
Permalink | Report
Answered Question
M$1
December 31, 2008 04:43 PM
In MS SQL 2005, is there a way to determine whether a specific node exists in an XML variable?
For example, say I have the following XML:
.... [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?
.... [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?
Interesting Question?
Yes (0)
No (0)
- In Web Development |
- |
- Report |
-
Share
RSS
Best Answer Chosen by Asker
| January 01, 2009 07:23 AM |
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.
Source(s):
http://msdn.microsoft.com/en-us/library/ms345117.aspx (under heading Example: Constraining XML Column)
| Asker's Rating: |
Permalink | Report
darth cont...
January 01, 2009 07:37 AM
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.
Tip darth continent for this comment
Report
Other Answers (1)
December 31, 2008 06:08 PM
It appears that SQL supports XML queries, but I would do this type of query on the application level. Here's an interesting article on SQL and XML: http://www.15seconds.com/Issue/050803.htm
Permalink | Report
Answer this Question
Related Questions
How can you truly feel happy for other people when nothing goes your way?
How has the recession affected you this holiday season?
How many stars in the Milky Way will be burning in 2.5 billion years when Andromedia ...
My previous employer did not pay into my SEP a small business version of a 401K. He ...
How has the recession affected you this holiday season?
How many stars in the Milky Way will be burning in 2.5 billion years when Andromedia ...
My previous employer did not pay into my SEP a small business version of a 401K. He ...
Ask a Question
Buy Mahalo Dollars with Credit Card or PayPal
Top Members
Most Popular Tags
Categories
- Anonymous
- Arts & Design
- Beauty & Style
- Books & Authors
- Business
- Cars & Transportation
- Consumer Electronics
- Coupons Deals
- Education
- Entertainment
- Environment
- Fitness
- Food & Drink
- From Email
- From Iphone
- From Twitter
- Health
- History
- Hobbies
- Home & Garden
- How Tos
- Humor
- Jobs
- Legal
- Local
- Love & Relationships
- Mahalo Answers Community
- Money
- Music
- News
- NSFW
- Parenting
- Pets
- Science & Mathematics
- Services
- Shopping
- Social Science
- Society & Culture
- Sports
- Technology & Internet
- Travel
- Video Games
Welcome New Members
- joujord, December 11, 2009 04:20 PM
- jordanaribeirod..., December 11, 2009 04:19 PM
- naked_lindsay, December 11, 2009 04:16 PM
- jmartpolitico, December 11, 2009 04:14 PM
- govardspacer, December 11, 2009 03:53 PM
Mahalo Dollars are the currency of Mahalo Answers.
Each Mahalo Dollar costs $1.
Once you earn more than 40 Mahalo Dollars, you can request to be paid via PayPal. Each Mahalo Dollar is currently worth $0.75 when paid out via PayPal. Learn More