Andy Green
asked on
Reading XML Node values (vb.net)
This is a sample of my config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<info>
<Import timeOfDay="07:30" fileTypes="txt" sourceFolder="C:\Pending" destinationFolder="C:\Proc essed" logFilePath="log.txt" />
</info>
</configuration>
There are lots of examples on how to get data from an XML file on the web, but my requirement is slightly different.
The key contains several values, how do I get each of them into local variables in my app.
If I could use the ConfigurationManager that would be great, but for now I'm resigned to just getting the data out.
Andy
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<info>
<Import timeOfDay="07:30" fileTypes="txt" sourceFolder="C:\Pending" destinationFolder="C:\Proc
</info>
</configuration>
There are lots of examples on how to get data from an XML file on the web, but my requirement is slightly different.
The key contains several values, how do I get each of them into local variables in my app.
If I could use the ConfigurationManager that would be great, but for now I'm resigned to just getting the data out.
Andy
By keys do you mean the attributes?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
indeed you can use this too
The variables (lists) will include ALL attributes from ALL
Dim StockDoc As XDocument = XDocument.Load("FullPathToYourFile.xml")
Dim xtimeOfDay = From kp In StockDoc.Root.Descendants("Import") Select kp.@<timeOfDay>
Dim xfileTypes = From kp In StockDoc.Root.Descendants Select kp.@<fileTypes>
Dim xsourceFolder = From kp In StockDoc.Root.Descendants Select kp.@<sourceFolder>
Dim xdestinationFolder = From kp In StockDoc.Root.Descendants Select kp.@<destinationFolder>
Dim xlogFilePath = From kp In StockDoc.Root.Descendants Select kp.@<logFilePath>
The variables (lists) will include ALL attributes from ALL
Import
XElements sequentially.
ASKER
Great thank you
Andy
Andy