for example,xml like
'<name>test</name><age>10</age>'
select ? from @.xml.nodes('/*')
how to get the node tag name like name and age?
thanks
You can try the following code:
XmlDocument doc =new XmlDocument(); doc.Load("yourpath.xml");//Select and display the value of all the ISBN attributes. XmlElement root = doc.DocumentElement;if (root.HasChildNodes) {for (int i = 0; i < root.ChildNodes.Count; i++) { Response.Write(root.ChildNodes[i].Name); } }Hope it helps.|||
Sorry. I didn't make it clear. What I want to know is how to get nodename in the SQL 2005 XML query.
Thanks anyway.
|||Hi
I triedSELECT [column1].query('data(/root/*)') FROM [xml_test] it returned the data value of the nodes.
But when I triedSELECT [column1].query('node-name(/root/*)') FROM [xml_test]
It produced an error said node-name which was defined in xpath was not supported.
Hope others have a good idea.
No comments:
Post a Comment