我正在开发一个asp.net c#应用程序。 XML
下方的Bookpoint
列{q}存储在我的数据库中,作为text
数据类型。
我只需要获取不同元素下的所有<Point>
个节点。我想在SQL Server 2008中使用XQuery来获取所有这些要点
<BreezyCalc xml:space="preserve" xmlns="http://microsoft.com">
<Graph Foreground="#FF000000">
<point>lines added</point>
<Graph/>
<Graph Foreground="#FF000000">
<point>lines added</point>
<point>two added</point>
<point>lines added</point>
<Graph />
<Graph Foreground="#FF000000">
<lines>
<point>lines Removed</point>
<point>lines added</point>
<lines/>
<Graph/>
<BreezyCalc/>
我的表结构
PointID Name BookPoint CreatedDate |
--------|--------------|---------------------------------------------|-------------------------------
1 | categoryname |<BreezyCalc xml:space="preserve" xmlns="http:|2011-04-05 12:28:15.030 |
2 | category1 |<BreezyCalc xml:space="preserve" xmlns="http:|2011-04-05 12:28:15.030 |
我在这里期待结果
1 |lines added
lines added
two added
lines added from firs column
2 |lines added, from second column
我已经阅读了这个脚本
Read XML document stored in SQL Server with text datatype?
;WITH XMLNAMESPACES(DEFAULT 'http://microsoft.com')
SELECT
PointID,
BookPoint.value('(/BreezyCalc/Graph/point)[1]', 'varchar(200)')
FROM BooksTable
where id=1
但结果为"lines added "
它只给我一个我有任何解决方案去获取所有<point>
节点请帮忙或请
否则,有人可以告诉我如何获取图表数据<point>
答案 0 :(得分:0)
SELECT PointID
,T.C.value('(.)[1]','varchar(50)') AS point
FROM BooksTable
CROSS APPLY BookPoint.nodes('/BreezyCalc/Graph/point') as T(C)
where id=1