Moonbathing
asked on
XML / VB.NET Simple Question... 500pts!
ok... I'm a beginer when it comes to XPATH / XML. Here is my XML File:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<Events>
<Event>
<Name>Sweetest Day @ Domaine Nightclub</Name>
<Date>10-16-04</Date>
<NumberOfPhotos>54</Number OfPhotos>
</Event>
<Event>
<Name>Thank You @ Sauce</Name>
<Date>10-01-04</Date>
<NumberOfPhotos>65</Number OfPhotos>
</Event>
</Events>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
I'm trying to just simply read the code in my VB.NET page and set it to String Vars knowing the date such as:
Dim theDate As String = "10-16-04"
Dim EventName = [XML Event Name accoicated with the value of theDate above]
Dim NumberOfPhotos = [XML Number of photos accoicated with the value of theDate above]
Can someone please tell me how to pull those values out? thanx!!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<Events>
<Event>
<Name>Sweetest Day @ Domaine Nightclub</Name>
<Date>10-16-04</Date>
<NumberOfPhotos>54</Number
</Event>
<Event>
<Name>Thank You @ Sauce</Name>
<Date>10-01-04</Date>
<NumberOfPhotos>65</Number
</Event>
</Events>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
I'm trying to just simply read the code in my VB.NET page and set it to String Vars knowing the date such as:
Dim theDate As String = "10-16-04"
Dim EventName = [XML Event Name accoicated with the value of theDate above]
Dim NumberOfPhotos = [XML Number of photos accoicated with the value of theDate above]
Can someone please tell me how to pull those values out? thanx!!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
When I complie I get a:
Compiler Error Message: BC30002: Type 'TextReader' is not defined.
Clearly cause I have imported the TextReader class... For some reason, I can't get it to work. Can someone tell me where to put my Imports statement? and what should I Import? (if I'm using Desp solution I think it's System.IO if I'm using AmanBrar Solution then I think it's XMLDocument class)
Here is my code:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<%@ Control Language="VB" Debug="true" %>
<script runat="server">
sub Page_Load()
Dim MyTextReader As TextReader = File.OpenText("Events.XML" )
Dim XMLString As String = MyTextReader.ReadToEnd()
Dim nList As XmlNodeList
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Where do I put the Imports statement and what do I Import?
Compiler Error Message: BC30002: Type 'TextReader' is not defined.
Clearly cause I have imported the TextReader class... For some reason, I can't get it to work. Can someone tell me where to put my Imports statement? and what should I Import? (if I'm using Desp solution I think it's System.IO if I'm using AmanBrar Solution then I think it's XMLDocument class)
Here is my code:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<%@ Control Language="VB" Debug="true" %>
<script runat="server">
sub Page_Load()
Dim MyTextReader As TextReader = File.OpenText("Events.XML"
Dim XMLString As String = MyTextReader.ReadToEnd()
Dim nList As XmlNodeList
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Where do I put the Imports statement and what do I Import?
plz add the following Imports on top of your .vb page:
Imports System.IO
Imports System.Xml
Imports System.IO
Imports System.Xml
Dim XMLString As String = MyTextReader.ReadToEnd()
Dim myXMLdocument As XmlDocument = New XmlDocument()
myXMLdocument.LoadXml(XMLS
Dim theDate As String = "10-16-04"
Dim EventName As String = myXMLdocument.GetElementsB
Dim NumberOfPhotos As String = myXMLdocument.GetElementsB
Console.WriteLine(theDate & " " & EventName & " " & NumberOfPhotos)