如何从xml检索数据 [英] how to retrieve data from xml
本文介绍了如何从xml检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从xml文档中检索数据...
说xml文档中有100个值,以各种字母开头..
现在,当我在文本框中输入"a"时,所有以"a"开头的值都应显示为类似于在其中输入值"a"的文本框的下拉列表.
我尝试使用Google搜索,但找不到方法.....
请帮助我
how to retrieve data from an xml document...
say there are 100 values in xml document starting with various alphabets ..
now when i enter "a" in a text box all values starting with "a" should display like a dropdown to the text box in which the value "a" is entered..
i tried googling but could not find how to do it .....
please help me
推荐答案
DECLARE @hDoc int
EXEC sp_xml_preparedocument @hDoc OUTPUT,
N'<ROOT>
<Customers CustomerID="XYZAA" ContactName="Joe"
CompanyName="Company1">
<Orders CustomerID="XYZAA"
OrderDate="2000-08-25T00:00:00"/>
<Orders CustomerID="XYZAA"
OrderDate="2000-10-03T00:00:00"/>
</Customers>
<Customers CustomerID="XYZBB" ContactName="Steve"
CompanyName="Company2">No Orders yet!
</Customers>
</ROOT>'
-- Use OPENXML to provide rowset consisting of customer data.
INSERT Customers
SELECT *
FROM OPENXML(@hDoc, N'/ROOT/Customers')
WITH Customers
-- Use OPENXML to provide rowset consisting of order data.
INSERT Orders
SELECT *
FROM OPENXML(@hDoc, N'//Orders')
WITH Orders
-- Using OPENXML in a SELECT statement.
SELECT * FROM OPENXML(@hDoc, N'/ROOT/Customers/Orders') with (CustomerID nchar(5) '../@CustomerID', OrderDate datetime)
-- Remove the internal representation of the XML document.
EXEC sp_xml_removedocument @hDoc
您可以使用linq,请检查下面的链接.
http://msdn.microsoft.com/en-us/library/bb308960.aspx [ ^ ]
您也可以使用XPathDocument和XPathNodeIterator查询XML.
http://www.java2s.com/Tutorial/ASP.NET/0500__XML/QueryingXMLwithXPathDocumentandXPathNodeIteratorC.htm [ ^ ]
您也可以应用XPath语法.
http://www.w3schools.com/xpath/xpath_syntax.asp [
You can use linq for that, check below link.
http://msdn.microsoft.com/en-us/library/bb308960.aspx[^]
Also you can querying XML with XPathDocument and XPathNodeIterator.
http://www.java2s.com/Tutorial/ASP.NET/0500__XML/QueryingXMLwithXPathDocumentandXPathNodeIteratorC.htm[^]
Also you can apply XPath Syntax.
http://www.w3schools.com/xpath/xpath_syntax.asp[^]
这篇关于如何从xml检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文