We have an in-house piece of software that works with loosely-defined XML files. I'm trying to extract the child nodes from this step in T-SQL. I'm able to extract the parent node, but I keep getting syntax errors whenever I query the children.
The XML file looks roughly like this:
<?xml version="1.0"?> <root> <steps> <step> <steptypeX attribute="somevalue"> <child1>Value</child1> <child2>Value</child2> </steptypeX> </step> </steps> </root> I'm using the following T-SQL:
select doc.col.query('/child*') --If I use '.' or '*' here I can get the children as XML, but I want the values contained within the nodes on separate rows from @xmldoc.nodes('/root/steps/step/steptypeX') doc(col) where doc.col.value('@attribute', 'nvarchar(max)') = 'somevalue' The error message I'm getting is not clear:
XQuery [query()]: Syntax error near '<eof>' As far as I can tell, the nodes do exist and I haven't left any XQuery instructions with trailing slashes. I can't really tell what I'm doing wrong here.
No comments:
Post a Comment