XMLTextReader

liunx

Guest
hi was wondering if anyone can help me .

I am using XMLTextReader to go through quite a simple xml document.

how do i refer to specif nodes that i want to go to eg node 1 question ID etc.

i tried Xread.ReadElementString("Answer").

Also a second question I am trying to make a XML creator for the above from than Access, SQL server (depends which is used) I know how to do it with SQL.

however how do you activate and read from access. and place it in to a dataset for processing.

basically using this but with the use of an access database.

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Xml" %>
<script language="VB" runat="server">

Sub Page_Load(sender as Object, e as EventArgs)
Dim myConnection As SqlConnection
Dim myCommand As SqlDataAdapter
Dim myDataSet As DataSet

' Create connection and set connection string
myConnection = New SqlConnection("Data Source=10.2.1.214;" _
& "Initial Catalog=samples;User Id=samples;Password=password;" _
& "Connect Timeout=15;Network Library=dbmssocn;")

' Create a new command object that uses our connection
' and set the text of the command to be executed
myCommand = New SqlDataAdapter("SELECT * FROM scratch ORDER BY id;", _
myConnection)

' Create a new dataset
myDataSet = New DataSet()

' This line changes the name of the outer container
' tags in the resulting xml file.
myDataSet.DataSetName = "something"

' Use the command to fill our DataSet
myCommand.Fill(myDataSet, "scratch")


' We've got our data... now save it to the output file:

' File paths
Dim strXsdPath As String = Server.MapPath("db_xml.xsd")
Dim strXmlPath As String = Server.MapPath("db_xml.xml")

' Write out schema to .xsd file and data to .xml file
myDataSet.WriteXmlSchema(strXsdPath)
myDataSet.WriteXml(strXmlPath, XmlWriteMode.IgnoreSchema)

' Could also write both schema and data to a single file
'myDataSet.WriteXml(strXmlPath, XmlWriteMode.WriteSchema)

' Or ignore the schema and just write data to .xml file
'myDataSet.WriteXml(strXmlPath)
End Sub

</script>

<html>
<head>
<title>ASP.NET ADO.NET to XML Sample</title>
</head>
<body>

<p>
XML file written...
click <a href=http://www.webdeveloper.com/forum/archive/index.php/"db_xml.xml">here</a> to view the .xml file.
</p>

<p>
XSD file written...
click <a href=http://www.webdeveloper.com/forum/archive/index.php/"db_xml.xsd">here</a> to view the .xsd file.
</p>

</body>
</html>
 
Top