H
HNguyen
Hi,
I have a problem of binding data from XQuery to a dataset. Here is the
program I've extracted from 4guysfromrolla.com. This program read data from
an XML file (Employees.xml) and performed XQuery from this XML file. The
program ran OK to show the XML data on the Literal control. Instead of
displaying XML data on that control, I'd like to bind XML data to a dataset
and display them on Datagrid control (not in XML data format). Please help
me to solve it !!!
My e-mail is (e-mail address removed)
Thanks in advance.
Hiep
================================================================
(Employees.aspx)
<%@ Page Language="vb" debug="true" %>
<%@ Import Namespace="Microsoft.Xml.XQuery" %>
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Dim col as New XQueryNavigatorCollection()
col.AddNavigator(Server.MapPath("Employees.xml"), "Emp")
Dim query as string
query="<Emp>{for $myNode in document(""Emp"")//Employees where
$myNode/Route=""K-22"" return $myNode}</Emp>"
Dim expr as New XQueryExpression(query)
lblXML.Text = (expr.Execute(col)).ToXml()
End sub
</script>
<html>
<body>
<xmp>
<asp:Literal runat="server" id="lblXML" />
</xmp>
</body>
</html>
=======================================================================
(Employees.xml)
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<Employees>
<ID>1</ID>
<LastName>Jackson</LastName>
<FirstName> Alan</FirstName>
<Phone>(703) 123-4567</Phone>
<Room>430</Room>
<Route>K-22</Route>
<Gov>1</Gov>
<Status>ND</Status>
</Employees>
<Employees>
<ID>2</ID>
<LastName>Robin</LastName>
<FirstName> Tim</FirstName>
<Phone>(703) 234-5678</Phone>
<Room>412</Room>
<Route>K-15</Route>
<Gov>0</Gov>
<Status>ND</Status>
</Employees>
<NewDataSet>
I have a problem of binding data from XQuery to a dataset. Here is the
program I've extracted from 4guysfromrolla.com. This program read data from
an XML file (Employees.xml) and performed XQuery from this XML file. The
program ran OK to show the XML data on the Literal control. Instead of
displaying XML data on that control, I'd like to bind XML data to a dataset
and display them on Datagrid control (not in XML data format). Please help
me to solve it !!!
My e-mail is (e-mail address removed)
Thanks in advance.
Hiep
================================================================
(Employees.aspx)
<%@ Page Language="vb" debug="true" %>
<%@ Import Namespace="Microsoft.Xml.XQuery" %>
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Dim col as New XQueryNavigatorCollection()
col.AddNavigator(Server.MapPath("Employees.xml"), "Emp")
Dim query as string
query="<Emp>{for $myNode in document(""Emp"")//Employees where
$myNode/Route=""K-22"" return $myNode}</Emp>"
Dim expr as New XQueryExpression(query)
lblXML.Text = (expr.Execute(col)).ToXml()
End sub
</script>
<html>
<body>
<xmp>
<asp:Literal runat="server" id="lblXML" />
</xmp>
</body>
</html>
=======================================================================
(Employees.xml)
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<Employees>
<ID>1</ID>
<LastName>Jackson</LastName>
<FirstName> Alan</FirstName>
<Phone>(703) 123-4567</Phone>
<Room>430</Room>
<Route>K-22</Route>
<Gov>1</Gov>
<Status>ND</Status>
</Employees>
<Employees>
<ID>2</ID>
<LastName>Robin</LastName>
<FirstName> Tim</FirstName>
<Phone>(703) 234-5678</Phone>
<Room>412</Room>
<Route>K-15</Route>
<Gov>0</Gov>
<Status>ND</Status>
</Employees>
<NewDataSet>