I'm trying to read two nodes in an xml file that I'm using to store setting
but I'm having a hard time trying to read the values of two nodes. Below I
can read one node but I need to be able to grab both values and I can't seem
to figure it out, just a bigginer. I'm able to grab aTime but can't get the
aType value. Should I create a second routine or is there something I can
stick in this to make it work for me. I just want those two value, the file
never changes just the values. Thanks
XML File
- <Sleep>
- <LastAlarm>
<aTime>5/28/2004 2:29:00 PM</aTime>
<aType>rdbLock</aType>
</LastAlarm>
</Sleep>
Code
Sub ReadXML()
Dim LastAlarm As String
Dim Doc As New XmlDocument
Dim Nav As XPath.XPathNavigator
Dim Iterator As XPath.XPathNodeIterator
'Load document.
Doc.Load(Application.StartupPath & "\" & "sleep.xml")
'Set nav object.
Nav = CType(Doc, XPath.IXPathNavigable).CreateNavigator()
'Set node iterator.
Iterator = Nav.Select("LastAlarm" & "aTime")
'Move to the desired node.
Iterator.MoveNext()
'Get the value of the current node.
LastAlarm = Iterator.Current.Value
End Sub 9 1307
In article <eN**************@TK2MSFTNGP11.phx.gbl>, bd***@hotmail.com
says... I'm trying to read two nodes in an xml file that I'm using to store setting but I'm having a hard time trying to read the values of two nodes. Below I can read one node but I need to be able to grab both values and I can't seem to figure it out, just a bigginer. I'm able to grab aTime but can't get the aType value. Should I create a second routine or is there something I can stick in this to make it work for me. I just want those two value, the file never changes just the values. Thanks
An XPath query would probably be quicker: http://www.w3schools.com/xpath/xpath_syntax.asp
--
Patrick Steele
Microsoft .NET MVP http://weblogs.asp.net/psteele
dim aTime as string = doc.documentelement.selectsinglenode("//aTime").valu
dim aType as string = doc.documentelement.selectsinglenode("//aType").valu
----- B-Dog wrote: ----
I'm trying to read two nodes in an xml file that I'm using to store settin
but I'm having a hard time trying to read the values of two nodes. Below
can read one node but I need to be able to grab both values and I can't see
to figure it out, just a bigginer. I'm able to grab aTime but can't get th
aType value. Should I create a second routine or is there something I ca
stick in this to make it work for me. I just want those two value, the fil
never changes just the values. Thank
XML Fil
- <Sleep
- <LastAlarm><aTime>5/28/2004 2:29:00 PM</aTime><aType>rdbLock</aType></LastAlarm></Sleep
Cod
Sub ReadXML(
Dim LastAlarm As Strin
Dim Doc As New XmlDocumen
Dim Nav As XPath.XPathNavigato
Dim Iterator As XPath.XPathNodeIterato
'Load document
Doc.Load(Application.StartupPath & "\" & "sleep.xml"
'Set nav object
Nav = CType(Doc, XPath.IXPathNavigable).CreateNavigator(
'Set node iterator
Iterator = Nav.Select("LastAlarm" & "aTime"
'Move to the desired node
Iterator.MoveNext(
'Get the value of the current node
LastAlarm = Iterator.Current.Valu
End Su
Thanks for the link I'll have a look.
"Patrick Steele [MVP]" <pa*****@mvps.org> wrote in message
news:MP************************@msnews.microsoft.c om... In article <eN**************@TK2MSFTNGP11.phx.gbl>, bd***@hotmail.com says... I'm trying to read two nodes in an xml file that I'm using to store
setting but I'm having a hard time trying to read the values of two nodes.
Below I can read one node but I need to be able to grab both values and I can't
seem to figure it out, just a bigginer. I'm able to grab aTime but can't get
the aType value. Should I create a second routine or is there something I
can stick in this to make it work for me. I just want those two value, the
file never changes just the values. Thanks
An XPath query would probably be quicker:
http://www.w3schools.com/xpath/xpath_syntax.asp
-- Patrick Steele Microsoft .NET MVP http://weblogs.asp.net/psteele
That is what I needed tman, I'll try it
Thanks!
"tMan" <an*******@discussions.microsoft.com> wrote in message
news:2E**********************************@microsof t.com... dim aTime as string =
doc.documentelement.selectsinglenode("//aTime").value dim aType as string =
doc.documentelement.selectsinglenode("//aType").value
----- B-Dog wrote: -----
I'm trying to read two nodes in an xml file that I'm using to store
setting but I'm having a hard time trying to read the values of two nodes.
Below I can read one node but I need to be able to grab both values and I
can't seem to figure it out, just a bigginer. I'm able to grab aTime but can't
get the aType value. Should I create a second routine or is there something
I can stick in this to make it work for me. I just want those two value,
the file never changes just the values. Thanks
XML File
- <Sleep> - <LastAlarm><aTime>5/28/2004 2:29:00
PM</aTime><aType>rdbLock</aType></LastAlarm></Sleep> Code
Sub ReadXML()
Dim LastAlarm As String
Dim Doc As New XmlDocument
Dim Nav As XPath.XPathNavigator
Dim Iterator As XPath.XPathNodeIterator
'Load document.
Doc.Load(Application.StartupPath & "\" & "sleep.xml")
'Set nav object.
Nav = CType(Doc, XPath.IXPathNavigable).CreateNavigator()
'Set node iterator.
Iterator = Nav.Select("LastAlarm" & "aTime")
'Move to the desired node.
Iterator.MoveNext()
'Get the value of the current node.
LastAlarm = Iterator.Current.Value End Sub
whats the exception message?
oh ok..my bad!
instead of value use innertext property
Dim aTime As String = Doc.DocumentElement.SelectSingleNode("//aTime").InnerTex
Dim aType As String = Doc.DocumentElement.SelectSingleNode("/aType").InnerText
Hmnn, I tried this below but doesn't give me a value, only my error message
Try
Dim Doc As New XmlDocument
'Load document.
Doc.Load(Application.StartupPath & "\" & "sleep.xml")
Dim aTime As String = Doc.DocumentElement.SelectSingleNode("//aTime").Value
Dim aType As String = Doc.DocumentElement.SelectSingleNode("/aType").Value
MsgBox(aTime)
Catch ex As Exception
MsgBox("error")
End Try
"tMan" <an*******@discussions.microsoft.com> wrote in message
news:2E**********************************@microsof t.com... dim aTime as string =
doc.documentelement.selectsinglenode("//aTime").value dim aType as string =
doc.documentelement.selectsinglenode("//aType").value
----- B-Dog wrote: -----
I'm trying to read two nodes in an xml file that I'm using to store
setting but I'm having a hard time trying to read the values of two nodes.
Below I can read one node but I need to be able to grab both values and I
can't seem to figure it out, just a bigginer. I'm able to grab aTime but can't
get the aType value. Should I create a second routine or is there something
I can stick in this to make it work for me. I just want those two value,
the file never changes just the values. Thanks
XML File
- <Sleep> - <LastAlarm><aTime>5/28/2004 2:29:00
PM</aTime><aType>rdbLock</aType></LastAlarm></Sleep> Code
Sub ReadXML()
Dim LastAlarm As String
Dim Doc As New XmlDocument
Dim Nav As XPath.XPathNavigator
Dim Iterator As XPath.XPathNodeIterator
'Load document.
Doc.Load(Application.StartupPath & "\" & "sleep.xml")
'Set nav object.
Nav = CType(Doc, XPath.IXPathNavigable).CreateNavigator()
'Set node iterator.
Iterator = Nav.Select("LastAlarm" & "aTime")
'Move to the desired node.
Iterator.MoveNext()
'Get the value of the current node.
LastAlarm = Iterator.Current.Value End Sub
Hi B-Dog,
I thought I would put in my 2 cents. http://kjmsolutions.com/xmlsettings.htm I'm trying to read two nodes in an xml file that I'm using to store
setting but I'm having a hard time trying to read the values of two nodes.
Thanks guys for all the help!
"scorpion53061" <sc************@nospamhereeveryahoo.com> wrote in message
news:OE**************@tk2msftngp13.phx.gbl... Hi B-Dog,
I thought I would put in my 2 cents.
http://kjmsolutions.com/xmlsettings.htm
I'm trying to read two nodes in an xml file that I'm using to store setting but I'm having a hard time trying to read the values of two nodes.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: ZafT |
last post by:
Thanks in advance for any tips that might get me going in the right
direction.
I am working on a simple exercise for school that is supposed to use read to
read a file (about 10 MB). I am...
|
by: Chua Wen Ching |
last post by:
Hi there,
I have some problems when reading XML file.
1. First this, is what i did, cause i can't seem to read "sub elements or
tags" values, so i place those values into attributes like this....
|
by: ruca |
last post by:
Hi,
Can I read a .TXT File to a DataSet? How can I do that?
I want to read his lines to a DropDownList. This lines are the names of
employees that I export from an application that I have.
I...
|
by: Dave Coate |
last post by:
Hello again,
I am going to re-post a question. I got some excellent suggestions from
Rob and Mattias on this but their ideas did not solve the problem. Here is
the original post:
...
|
by: dosworldguy |
last post by:
I have been having a very peculiar issue from a long time.
I have an application where multiple clients read from a shared set of
files. When a record is changed, sometimes the win9x clients...
|
by: Mr. SweatyFinger |
last post by:
where have they all gone.
alt.suicide?
alt.findContol.then.slit.your.own.throat?
|
by: flebber |
last post by:
I was working at creating a simple program that would read the content
of a playlist file( in this case *.k3b") and write it out . the
compressed "*.k3b" file has two file and the one I was trying...
|
by: Hollywood |
last post by:
Hello members of the comp.lang.c++,
My log file is made of a set of 1000 following lines kind:
21/09/07 13:49:56,MW.SET.D_IGLS,2.000000
21/09/07 13:49:56,MW.SET.GNP_NT,7.000000
.....
...
|
by: Rahul Babbar |
last post by:
Hi,
I had the following doubts about the "For Read Only" clause.
1. How does a "for Read only" clause improve the performance?
2. How does a "for Read only" clause compare with "With UR"...
|
by: rohit |
last post by:
Hi All,
I am new to C language.I want to read integers from a text file and
want to do some operation in the main program.To be more specific I
need to multiply each of these integers with another...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |