Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
Amir Mahfoozi 11-Jan-12 7:26am    
Give an example please.

SQL
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
 
Share this answer
 
v2
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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900