loading XML data into an ArrayList

K

kaczmar2

I have the following code which is working:

*** XML FILE ***
<?xml version="1.0" encoding="utf-8" ?>
<FileTypes>
<FileType name="index.html" />
<FileType name="index.asp" />
<FileType name="default.htm" />
<FileType name="default.html" />
<FileType name="default.asp" />
<FileType name="default.aspx" />
</FileTypes>


*** ASP.NET CODEBEHIND ***

Dim oXMLDoc As New XmlDocument
Dim oNodes As XmlNodeList
Dim oNode As XmlNode
Dim aryFileTypes As ArrayList = New ArrayList

' Load from XML file
oXMLDoc.Load(Server.MapPath(ConfigurationSettings.AppSettings("FileTypesPath")))
oNodes = oXMLDoc.SelectNodes("/FileTypes/FileType/@name")

' Add these XML nodes to array
For Each oNode In oNodes
aryFileTypes.Add(oNode.Value)
Next

My question is, since this XML file is so simple, and has (and always
will have, just a simple list of nodes like this, is there a better way
to bind this data to an array list? I know this isn't much code, but I
was just wondering. FOr example, is there a simple way to bind XML
data directly to an ArrayList, as you can with a dataset:

Dim dsSitesOther As New DataSet
dsSitesOther.ReadXml(Server.MapPath(ConfigurationSettings.AppSettings("OtherSitesPath")))

I am searching/manipulating the data in the array, so that is why I
don't want to load it into a a web control of some kind.

Thanks,

Christian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,174
Latest member
BlissKetoACV
Top