Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: getting overwhelmed...reading and testing


Message #1 by <cindy.somerville@h...> on Tue, 5 Nov 2002 12:25:26 -0500
How was I doing it in Access? I was able to extract just the files I needed 
with an SQL statement. Then I used the OleDbDataReader to read through each 
record and format depending on the date comparison with 'testDate'.
I should have mentioned that I'm using C#.

Right now I have a  for loop with nested if's to read through the file and 
display the records as required. I'm using a the dataSet and dataTable.  But, 
they are being displayed in reverse order. 

I then attempted to use the dataTable.Select method. I haven't been able to 
get the results I want and my code seems very complex and very long.  Should 
I continue with what I'm doing? Or am I going about it the wrong way? 

The .Net seems to have soooo much available, yet I feel like I'm building a 
house with toothpicks when I should be using planks and drywall. 


---------- Original Text ----------

From: "Paul Riley" <rilez@t...>, on 2002-11-05 10:56 AM:

SUBJECT too long. Original SUBJECT is
[aspx_beginners] RE: getting overwhelmed...reading and testing XML


----------------------  Original Message Follows  ----------------------

The following will parse the file

	dim objXMLdoc as new xmldatadocument(),raa,raa2 as xmlnode
	objxmldoc.load("c:\inetpub\wwwroot\test page.xml")
	for each raa in objxmldoc.childnodes
		response.write(raa.name & "<br>")
		if raa.name="page" then
			for each raa2 in raa.childnodes
				response.write(raa2.name)
			next
		end if
	next

it's a very very basic but you should be able to iterate through until
you find the nodes you want and then so the tests. How were you doing
the same thing in Access as there may be something closer to the way you
used to be working. 

-----Original Message-----
From: Cindy.Somerville@h...
[mailto:Cindy.Somerville@h...] 
Sent: 05 November 2002 15:41
To: aspx_beginners
Subject: [aspx_beginners] getting overwhelmed...reading and testing XML

I'm getting overwhelmed!

I'm a computer programming student in a co-op placement. I have been
given 
a task to do involving an XML file and dynamically displaying selected 
records to a web page. 

I'm starting to feel overwhelmed with the options for completing the
task 
assigned to me. I really need some advice on which direction to take
this. 
Could someone please point me in the right direction!

My task is to read an XML file. 
Test the date field to ensure that it is >= testDate.
Then I have to test the language field for English or French.
Then I have to compare the date field with the date field in the
previous 
row.this will determine the formatting of the record. 

I completed all this successfully when my data was in an access 
database...but someone decided that I needed to use XML instead. So, I'm

starting over!!!

I've tried XMLReader, dataSets, dataTables, nested if statements, 
table.select method. Each time I hit a wall. Should I be trying
XMLReader 
again? Should I continue with dataTables? 

If there is somebody out there that knows this stuff..could you please 
give me some advice as to which direction I should be going in to
complete 
this task. 

Getting desperate and need help!!

Thank you
---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=1861006195

Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=1861007418

These books look at how we can create data-centric ASP.NET 
applications. Requiring some basic knowledge of ASP.NET, 
Access and SQL the authors guide you through the process 
of connecting and consuming information in a variety of 
ways. They are packed full of excellent illustrative code 
examples, demonstrating important fundamental principles.


---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=1861006195

Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=1861007418

These books look at how we can create data-centric ASP.NET 
applications. Requiring some basic knowledge of ASP.NET, 
Access and SQL the authors guide you through the process 
of connecting and consuming information in a variety of 
ways. They are packed full of excellent illustrative code 
examples, demonstrating important fundamental principles.

Message #2 by "Paul Riley" <rilez@t...> on Tue, 5 Nov 2002 18:35:00 -0000
Ok Below is another way of doing it. I think you might be getting a
little too caught up with seeing XML as a database. It is also just a
text file and can be parsed as such. The dataset way of doing things
does have it's merits but I find it more confusing myself. Below is
something that will work (or at least it does for me) and it helped me
learn. End of the day I'm in the same boat I need to display and edit
XML from inside asp.net as part of my final year project. When it comes
to building a house out of toothpicks - I'm more a duplo sort of
developer :). Good luck
Example based on one from Wrox asp.net Pro

<%@Page Language="VB" %>
<%@Import Namespace="System.XML" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<title>Accessing an XML document with an XMLTextReader object</title>
<link rel="stylesheet" href="/include/style.css"/>
</head>
<body bgcolor="#ffffff">
<h1>Accessing an XML document with an XMLTextReader object</h1>

<div id="outDocURL" runat="server"></div>
<div id="outError" runat="server">&nbsp;</div>
<div id="outResults" runat="server"></div>

<script language="vb" runat="server">

Sub Page_Load()

   'create physical path to booklist.xml sample file (in same folder as
ASPX page)
   Dim strCurrentPath As String = Request.PhysicalPath
   Dim strXMLPath As String = Left(strCurrentPath,
InStrRev(strCurrentPath, "\")) & "test page.xml"

   'declare a variable to hold an XmlTextReader object
   Dim objXMLReader As XmlTextReader

   Try

      'create a new XmlTextReader object for the XML file
      objXMLReader = New XmlTextReader(strXMLPath)
      outDocURL.innerHTML = "Opened file: <b>" & strXMLPath & "</b>"

   Catch objError As Exception

      'display error details
      outError.innerHTML = "<b>* Error while accessing document</b>.<br
/>" _
          & objError.Message & "<br />" & objError.Source
      Exit Sub  ' and stop execution

   End Try

   'now ready to read (or "pull") the nodes of the XML document
   Dim strNodeResult As String = ""
   Dim objNodeType As XmlNodeType

   'read each node in turn - returns False if no more nodes to read
   Do While objXMLReader.Read()

      'select on the type of the node (these are only some of the types)
      objNodeType = objXMLReader.NodeType

      Select Case objNodeType

        Case XmlNodeType.XmlDeclaration:
           'get the name and value
           strNodeResult += "XML Declaration: <b>" & objXMLReader.Name _
                         & " " & objXMLReader.Value & "</b><br />"

        Case XmlNodeType.Element:
           'just get the name, any value will be in next (#text) node
           strNodeResult += "Element: <b>" & objXMLReader.Name &
"</b><br />"

        Case XmlNodeType.Text:
           'just display the value, node name is "#text" in this case
           strNodeResult += "&nbsp; - Value: <b>" & objXMLReader.Value _
                         & "</b><br />"
	
	Case XmlNodeType.CDATA:
           'just display the value, node name is "#text" in this case
           strNodeResult += "&nbsp; - Value: <b>" & objXMLReader.Value _
                         & "</b><br />"

      End Select

      'see if this node has any attributes
      If objXMLReader.AttributeCount > 0 Then

         'iterate through the attributes by moving to the next one
         'could use MoveToFirstAttribute but MoveToNextAttribute does
         'the same when the current node is an element-type node
         Do While objXMLReader.MoveToNextAttribute()

            'get the attribute name and value
            strNodeResult +=  "&nbsp; - Attribute: <b>" &
objXMLReader.Name _
                          & "</b> &nbsp; Value: <b>" &
objXMLReader.Value _
                          & "</b><br />"
         Loop

      End If

   Loop   'and read the next node

   'finished with the reader so close it
   objXMLReader.Close()

   'and display the results in the page
   outResults.innerHTML = strNodeResult

End Sub

</script>
</body>
</html>

-----Original Message-----
From: cindy.somerville@h...
[mailto:cindy.somerville@h...] 
Sent: 05 November 2002 17:25
To: aspx_beginners
Subject: [aspx_beginners] getting overwhelmed...reading and testing

How was I doing it in Access? I was able to extract just the files I
needed 
with an SQL statement. Then I used the OleDbDataReader to read through
each 
record and format depending on the date comparison with 'testDate'.
I should have mentioned that I'm using C#.

Right now I have a  for loop with nested if's to read through the file
and 
display the records as required. I'm using a the dataSet and dataTable.
But, 
they are being displayed in reverse order. 

I then attempted to use the dataTable.Select method. I haven't been able
to 
get the results I want and my code seems very complex and very long.
Should 
I continue with what I'm doing? Or am I going about it the wrong way? 

The .Net seems to have soooo much available, yet I feel like I'm
building a 
house with toothpicks when I should be using planks and drywall. 


---------- Original Text ----------

From: "Paul Riley" <rilez@t...>, on 2002-11-05 10:56 AM:

SUBJECT too long. Original SUBJECT is
[aspx_beginners] RE: getting overwhelmed...reading and testing XML


----------------------  Original Message Follows  ----------------------

The following will parse the file

	dim objXMLdoc as new xmldatadocument(),raa,raa2 as xmlnode
	objxmldoc.load("c:\inetpub\wwwroot\test page.xml")
	for each raa in objxmldoc.childnodes
		response.write(raa.name & "<br>")
		if raa.name="page" then
			for each raa2 in raa.childnodes
				response.write(raa2.name)
			next
		end if
	next

it's a very very basic but you should be able to iterate through until
you find the nodes you want and then so the tests. How were you doing
the same thing in Access as there may be something closer to the way you
used to be working. 

-----Original Message-----
From: Cindy.Somerville@h...
[mailto:Cindy.Somerville@h...] 
Sent: 05 November 2002 15:41
To: aspx_beginners
Subject: [aspx_beginners] getting overwhelmed...reading and testing XML

I'm getting overwhelmed!

I'm a computer programming student in a co-op placement. I have been
given 
a task to do involving an XML file and dynamically displaying selected 
records to a web page. 

I'm starting to feel overwhelmed with the options for completing the
task 
assigned to me. I really need some advice on which direction to take
this. 
Could someone please point me in the right direction!

My task is to read an XML file. 
Test the date field to ensure that it is >= testDate.
Then I have to test the language field for English or French.
Then I have to compare the date field with the date field in the
previous 
row.this will determine the formatting of the record. 

I completed all this successfully when my data was in an access 
database...but someone decided that I needed to use XML instead. So, I'm

starting over!!!

I've tried XMLReader, dataSets, dataTables, nested if statements, 
table.select method. Each time I hit a wall. Should I be trying
XMLReader 
again? Should I continue with dataTables? 

If there is somebody out there that knows this stuff..could you please 
give me some advice as to which direction I should be going in to
complete 
this task. 

Getting desperate and need help!!

Thank you
---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=1861006195

Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=1861007418

These books look at how we can create data-centric ASP.NET 
applications. Requiring some basic knowledge of ASP.NET, 
Access and SQL the authors guide you through the process 
of connecting and consuming information in a variety of 
ways. They are packed full of excellent illustrative code 
examples, demonstrating important fundamental principles.


---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=1861006195

Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=1861007418

These books look at how we can create data-centric ASP.NET 
applications. Requiring some basic knowledge of ASP.NET, 
Access and SQL the authors guide you through the process 
of connecting and consuming information in a variety of 
ways. They are packed full of excellent illustrative code 
examples, demonstrating important fundamental principles.


---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=1861006195

Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=1861007418

These books look at how we can create data-centric ASP.NET 
applications. Requiring some basic knowledge of ASP.NET, 
Access and SQL the authors guide you through the process 
of connecting and consuming information in a variety of 
ways. They are packed full of excellent illustrative code 
examples, demonstrating important fundamental principles.

Message #3 by <cindy.somerville@h...> on Wed, 6 Nov 2002 13:26:38 -0500
Thanks for the help Paul. 
I looked into the reader, but decided to go with the dataSet/dataTable.
I used a for loop, reading the file in reverse, with 3 nested if's to test 
the required fields...or nodes. I believe the fields are actually 
nodes...right?  I'm still trying to figure out exactly what a node is. 

Thanks ,
Cindy
---------- Original Text ----------

From: "Paul Riley" <rilez@t...>, on 2002-11-05 1:35 PM:

Ok Below is another way of doing it. I think you might be getting a
little too caught up with seeing XML as a database. It is also just a
text file and can be parsed as such. The dataset way of doing things
does have it's merits but I find it more confusing myself. Below is
something that will work (or at least it does for me) and it helped me
learn. End of the day I'm in the same boat I need to display and edit
XML from inside asp.net as part of my final year project. When it comes
to building a house out of toothpicks - I'm more a duplo sort of
developer :). Good luck
Example based on one from Wrox asp.net Pro

<%@Page Language="VB" %>
<%@Import Namespace="System.XML" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<title>Accessing an XML document with an XMLTextReader object</title>
<link rel="stylesheet" href="/include/style.css"/>
</head>
<body bgcolor="#ffffff">
<h1>Accessing an XML document with an XMLTextReader object</h1>

<div id="outDocURL" runat="server"></div>
<div id="outError" runat="server">&nbsp;</div>
<div id="outResults" runat="server"></div>

<script language="vb" runat="server">

Sub Page_Load()

   'create physical path to booklist.xml sample file (in same folder as
ASPX page)
   Dim strCurrentPath As String = Request.PhysicalPath
   Dim strXMLPath As String = Left(strCurrentPath,
InStrRev(strCurrentPath, "\")) & "test page.xml"

   'declare a variable to hold an XmlTextReader object
   Dim objXMLReader As XmlTextReader

   Try

      'create a new XmlTextReader object for the XML file
      objXMLReader = New XmlTextReader(strXMLPath)
      outDocURL.innerHTML = "Opened file: <b>" & strXMLPath & "</b>"

   Catch objError As Exception

      'display error details
      outError.innerHTML = "<b>* Error while accessing document</b>.<br
/>" _
          & objError.Message & "<br />" & objError.Source
      Exit Sub  ' and stop execution

   End Try

   'now ready to read (or "pull") the nodes of the XML document
   Dim strNodeResult As String = ""
   Dim objNodeType As XmlNodeType

   'read each node in turn - returns False if no more nodes to read
   Do While objXMLReader.Read()

      'select on the type of the node (these are only some of the types)
      objNodeType = objXMLReader.NodeType

      Select Case objNodeType

        Case XmlNodeType.XmlDeclaration:
           'get the name and value
           strNodeResult += "XML Declaration: <b>" & objXMLReader.Name _
                         & " " & objXMLReader.Value & "</b><br />"

        Case XmlNodeType.Element:
           'just get the name, any value will be in next (#text) node
           strNodeResult += "Element: <b>" & objXMLReader.Name &
"</b><br />"

        Case XmlNodeType.Text:
           'just display the value, node name is "#text" in this case
           strNodeResult += "&nbsp; - Value: <b>" & objXMLReader.Value _
                         & "</b><br />"
	
	Case XmlNodeType.CDATA:
           'just display the value, node name is "#text" in this case
           strNodeResult += "&nbsp; - Value: <b>" & objXMLReader.Value _
                         & "</b><br />"

      End Select

      'see if this node has any attributes
      If objXMLReader.AttributeCount > 0 Then

         'iterate through the attributes by moving to the next one
         'could use MoveToFirstAttribute but MoveToNextAttribute does
         'the same when the current node is an element-type node
         Do While objXMLReader.MoveToNextAttribute()

            'get the attribute name and value
            strNodeResult +=  "&nbsp; - Attribute: <b>" &
objXMLReader.Name _
                          & "</b> &nbsp; Value: <b>" &
objXMLReader.Value _
                          & "</b><br />"
         Loop

      End If

   Loop   'and read the next node

   'finished with the reader so close it
   objXMLReader.Close()

   'and display the results in the page
   outResults.innerHTML = strNodeResult

End Sub

</script>
</body>
</html>

-----Original Message-----
From: cindy.somerville@h...
[mailto:cindy.somerville@h...] 
Sent: 05 November 2002 17:25
To: aspx_beginners
Subject: [aspx_beginners] getting overwhelmed...reading and testing

How was I doing it in Access? I was able to extract just the files I
needed 
with an SQL statement. Then I used the OleDbDataReader to read through
each 
record and format depending on the date comparison with 'testDate'.
I should have mentioned that I'm using C#.

Right now I have a  for loop with nested if's to read through the file
and 
display the records as required. I'm using a the dataSet and dataTable.
But, 
they are being displayed in reverse order. 

I then attempted to use the dataTable.Select method. I haven't been able
to 
get the results I want and my code seems very complex and very long.
Should 
I continue with what I'm doing? Or am I going about it the wrong way? 

The .Net seems to have soooo much available, yet I feel like I'm
building a 
house with toothpicks when I should be using planks and drywall. 


---------- Original Text ----------

From: "Paul Riley" <rilez@t...>, on 2002-11-05 10:56 AM:

SUBJECT too long. Original SUBJECT is
[aspx_beginners] RE: getting overwhelmed...reading and testing XML


----------------------  Original Message Follows  ----------------------

The following will parse the file

	dim objXMLdoc as new xmldatadocument(),raa,raa2 as xmlnode
	objxmldoc.load("c:\inetpub\wwwroot\test page.xml")
	for each raa in objxmldoc.childnodes
		response.write(raa.name & "<br>")
		if raa.name="page" then
			for each raa2 in raa.childnodes
				response.write(raa2.name)
			next
		end if
	next

it's a very very basic but you should be able to iterate through until
you find the nodes you want and then so the tests. How were you doing
the same thing in Access as there may be something closer to the way you
used to be working. 

-----Original Message-----
From: Cindy.Somerville@h...
[mailto:Cindy.Somerville@h...] 
Sent: 05 November 2002 15:41
To: aspx_beginners
Subject: [aspx_beginners] getting overwhelmed...reading and testing XML

I'm getting overwhelmed!

I'm a computer programming student in a co-op placement. I have been
given 
a task to do involving an XML file and dynamically displaying selected 
records to a web page. 

I'm starting to feel overwhelmed with the options for completing the
task 
assigned to me. I really need some advice on which direction to take
this. 
Could someone please point me in the right direction!

My task is to read an XML file. 
Test the date field to ensure that it is >= testDate.
Then I have to test the language field for English or French.
Then I have to compare the date field with the date field in the
previous 
row.this will determine the formatting of the record. 

I completed all this successfully when my data was in an access 
database...but someone decided that I needed to use XML instead. So, I'm

starting over!!!

I've tried XMLReader, dataSets, dataTables, nested if statements, 
table.select method. Each time I hit a wall. Should I be trying
XMLReader 
again? Should I continue with dataTables? 

If there is somebody out there that knows this stuff..could you please 
give me some advice as to which direction I should be going in to
complete 
this task. 

Getting desperate and need help!!

Thank you
---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=1861006195

Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=1861007418

These books look at how we can create data-centric ASP.NET 
applications. Requiring some basic knowledge of ASP.NET, 
Access and SQL the authors guide you through the process 
of connecting and consuming information in a variety of 
ways. They are packed full of excellent illustrative code 
examples, demonstrating important fundamental principles.


---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=1861006195

Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=1861007418

These books look at how we can create data-centric ASP.NET 
applications. Requiring some basic knowledge of ASP.NET, 
Access and SQL the authors guide you through the process 
of connecting and consuming information in a variety of 
ways. They are packed full of excellent illustrative code 
examples, demonstrating important fundamental principles.


---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=1861006195

Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=1861007418

These books look at how we can create data-centric ASP.NET 
applications. Requiring some basic knowledge of ASP.NET, 
Access and SQL the authors guide you through the process 
of connecting and consuming information in a variety of 
ways. They are packed full of excellent illustrative code 
examples, demonstrating important fundamental principles.


---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=1861006195

Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=1861007418

These books look at how we can create data-centric ASP.NET 
applications. Requiring some basic knowledge of ASP.NET, 
Access and SQL the authors guide you through the process 
of connecting and consuming information in a variety of 
ways. They are packed full of excellent illustrative code 
examples, demonstrating important fundamental principles.

Message #4 by "Paul Riley" <rilez@t...> on Wed, 6 Nov 2002 20:24:39 -0000
Yeah the fields can be thought of as nodes. Nodes are anything from an
element to the attribute of that element. It's all a bit mad to be
honest. One problem I've just got round was that I was storing data in a
CDATA node which is supposed to allow symbols. It didn't however like 
=A3
signs so I had to replace all instances of them with &#163; - Took me a
while to figure that one out. Just in case someone else has the same
problem :)

All the best

-----Original Message-----
From: cindy.somerville@h...
[mailto:cindy.somerville@h...]
Sent: 06 November 2002 18:27
To: aspx_beginners
Subject: [aspx_beginners] RE: getting overwhelmed...reading and testing

Thanks for the help Paul.
I looked into the reader, but decided to go with the dataSet/dataTable.
I used a for loop, reading the file in reverse, with 3 nested if's to
test
the required fields...or nodes. I believe the fields are actually
nodes...right?  I'm still trying to figure out exactly what a node is.

Thanks ,
Cindy
---------- Original Text ----------

From: "Paul Riley" <rilez@t...>, on 2002-11-05 1:35 PM:

Ok Below is another way of doing it. I think you might be getting a
little too caught up with seeing XML as a database. It is also just a
text file and can be parsed as such. The dataset way of doing things
does have it's merits but I find it more confusing myself. Below is
something that will work (or at least it does for me) and it helped me
learn. End of the day I'm in the same boat I need to display and edit
XML from inside asp.net as part of my final year project. When it comes
to building a house out of toothpicks - I'm more a duplo sort of
developer :). Good luck
Example based on one from Wrox asp.net Pro

<%@Page Language=3D"VB" %>
<%@Import Namespace=3D"System.XML" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<title>Accessing an XML document with an XMLTextReader object</title>
<link rel=3D"stylesheet" href=3D"/include/style.css"/>
</head>
<body bgcolor=3D"#ffffff">
<h1>Accessing an XML document with an XMLTextReader object</h1>

<div id=3D"outDocURL" runat=3D"server"></div>
<div id=3D"outError" runat=3D"server">&nbsp;</div>
<div id=3D"outResults" runat=3D"server"></div>

<script language=3D"vb" runat=3D"server">

Sub Page_Load()

   'create physical path to booklist.xml sample file (in same folder as
ASPX page)
   Dim strCurrentPath As String =3D Request.PhysicalPath
   Dim strXMLPath As String =3D Left(strCurrentPath,
InStrRev(strCurrentPath, "\")) & "test page.xml"

   'declare a variable to hold an XmlTextReader object
   Dim objXMLReader As XmlTextReader

   Try

      'create a new XmlTextReader object for the XML file
      objXMLReader =3D New XmlTextReader(strXMLPath)
      outDocURL.innerHTML =3D "Opened file: <b>" & strXMLPath & "</b>"

   Catch objError As Exception

      'display error details
      outError.innerHTML =3D "<b>* Error while accessing 
document</b>.<br
/>" _
          & objError.Message & "<br />" & objError.Source
      Exit Sub  ' and stop execution

   End Try

   'now ready to read (or "pull") the nodes of the XML document
   Dim strNodeResult As String =3D ""
   Dim objNodeType As XmlNodeType

   'read each node in turn - returns False if no more nodes to read
   Do While objXMLReader.Read()

      'select on the type of the node (these are only some of the types)
      objNodeType =3D objXMLReader.NodeType

      Select Case objNodeType

        Case XmlNodeType.XmlDeclaration:
           'get the name and value
           strNodeResult +=3D "XML Declaration: <b>" & objXMLReader.Name 
_
                         & " " & objXMLReader.Value & "</b><br />"

        Case XmlNodeType.Element:
           'just get the name, any value will be in next (#text) node
           strNodeResult +=3D "Element: <b>" & objXMLReader.Name &
"</b><br />"

        Case XmlNodeType.Text:
           'just display the value, node name is "#text" in this case
           strNodeResult +=3D "&nbsp; - Value: <b>" & objXMLReader.Value 
_
                         & "</b><br />"
=09
	Case XmlNodeType.CDATA:
           'just display the value, node name is "#text" in this case
           strNodeResult +=3D "&nbsp; - Value: <b>" & objXMLReader.Value 
_
                         & "</b><br />"

      End Select

      'see if this node has any attributes
      If objXMLReader.AttributeCount > 0 Then

         'iterate through the attributes by moving to the next one
         'could use MoveToFirstAttribute but MoveToNextAttribute does
         'the same when the current node is an element-type node
         Do While objXMLReader.MoveToNextAttribute()

            'get the attribute name and value
            strNodeResult +=3D  "&nbsp; - Attribute: <b>" &
objXMLReader.Name _
                          & "</b> &nbsp; Value: <b>" &
objXMLReader.Value _
                          & "</b><br />"
         Loop

      End If

   Loop   'and read the next node

   'finished with the reader so close it
   objXMLReader.Close()

   'and display the results in the page
   outResults.innerHTML =3D strNodeResult

End Sub

</script>
</body>
</html>

-----Original Message-----
From: cindy.somerville@h...
[mailto:cindy.somerville@h...]
Sent: 05 November 2002 17:25
To: aspx_beginners
Subject: [aspx_beginners] getting overwhelmed...reading and testing

How was I doing it in Access? I was able to extract just the files I
needed
with an SQL statement. Then I used the OleDbDataReader to read through
each
record and format depending on the date comparison with 'testDate'.
I should have mentioned that I'm using C#.

Right now I have a  for loop with nested if's to read through the file
and
display the records as required. I'm using a the dataSet and dataTable.
But,
they are being displayed in reverse order.

I then attempted to use the dataTable.Select method. I haven't been able
to
get the results I want and my code seems very complex and very long.
Should
I continue with what I'm doing? Or am I going about it the wrong way?

The .Net seems to have soooo much available, yet I feel like I'm
building a
house with toothpicks when I should be using planks and drywall.


---------- Original Text ----------

From: "Paul Riley" <rilez@t...>, on 2002-11-05 10:56 AM:

SUBJECT too long. Original SUBJECT is
[aspx_beginners] RE: getting overwhelmed...reading and testing XML


----------------------  Original Message Follows  ----------------------

The following will parse the file

	dim objXMLdoc as new xmldatadocument(),raa,raa2 as xmlnode
	objxmldoc.load("c:\inetpub\wwwroot\test page.xml")
	for each raa in objxmldoc.childnodes
		response.write(raa.name & "<br>")
		if raa.name=3D"page" then
			for each raa2 in raa.childnodes
				response.write(raa2.name)
			next
		end if
	next

it's a very very basic but you should be able to iterate through until
you find the nodes you want and then so the tests. How were you doing
the same thing in Access as there may be something closer to the way you
used to be working.

-----Original Message-----
From: Cindy.Somerville@h...
[mailto:Cindy.Somerville@h...]
Sent: 05 November 2002 15:41
To: aspx_beginners
Subject: [aspx_beginners] getting overwhelmed...reading and testing XML

I'm getting overwhelmed!

I'm a computer programming student in a co-op placement. I have been
given
a task to do involving an XML file and dynamically displaying selected
records to a web page.

I'm starting to feel overwhelmed with the options for completing the
task
assigned to me. I really need some advice on which direction to take
this.
Could someone please point me in the right direction!

My task is to read an XML file.
Test the date field to ensure that it is >=3D testDate.
Then I have to test the language field for English or French.
Then I have to compare the date field with the date field in the
previous
row.this will determine the formatting of the record.

I completed all this successfully when my data was in an access
database...but someone decided that I needed to use XML instead. So, I'm

starting over!!!

I've tried XMLReader, dataSets, dataTables, nested if statements,
table.select method. Each time I hit a wall. Should I be trying
XMLReader
again? Should I continue with dataTables?

If there is somebody out there that knows this stuff..could you please
give me some advice as to which direction I should be going in to
complete
this task.

Getting desperate and need help!!

Thank you
---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=3D1861006195

Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=3D1861007418

These books look at how we can create data-centric ASP.NET
applications. Requiring some basic knowledge of ASP.NET,
Access and SQL the authors guide you through the process
of connecting and consuming information in a variety of
ways. They are packed full of excellent illustrative code
examples, demonstrating important fundamental principles.


---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=3D1861006195

Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=3D1861007418

These books look at how we can create data-centric ASP.NET
applications. Requiring some basic knowledge of ASP.NET,
Access and SQL the authors guide you through the process
of connecting and consuming information in a variety of
ways. They are packed full of excellent illustrative code
examples, demonstrating important fundamental principles.


---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=3D1861006195

Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=3D1861007418

These books look at how we can create data-centric ASP.NET
applications. Requiring some basic knowledge of ASP.NET,
Access and SQL the authors guide you through the process
of connecting and consuming information in a variety of
ways. They are packed full of excellent illustrative code
examples, demonstrating important fundamental principles.


---
Beginning ASP.NET Databases using VB.NET
http://www.wrox.com/ACON11.asp?ISBN=3D1861006195

Beginning ASP.NET Databases using C#
http://www.wrox.com/ACON11.asp?ISBN=3D1861007418

These books look at how we can create data-centric ASP.NET
applications. Requiring some basic knowledge of ASP.NET,
Access and SQL the authors guide you through the process
of connecting and consuming information in a variety of
ways. They are packed full of excellent illustrative code
examples, demonstrating important fundamental principles.




  Return to Index