473,408 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

loading XML data into an ArrayList

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(ConfigurationS ettings.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

Nov 19 '05 #1
1 3076
Christian,

I would strongly suggest that you look into XML Serialization. It will make
your life much, much easier.

http://msdn.microsoft.com/library/de...ml01202003.asp

http://msdn.microsoft.com/library/de...ClassTopic.asp

http://msdn.microsoft.com/library/de...serializer.asp

HTH,
~d
<ka******@hotmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
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(ConfigurationS ettings.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

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Ender | last post by:
I have an application that I would like third party developers to be able to create Plug-ins that will be dynamically loaded into our application to extend functionality. I have utilized the...
1
by: davehunt | last post by:
Hi folks, New C# programmer here. I am reading some CSV data from a file into an ArrayList. I want to get the data from the ArrayList into a 2-dimensional array. I see a few references to...
9
by: shadow.demon | last post by:
G'day, I've separated my database calls into a separate dll, and return results from any database calls as a SqlDataReader (because of SQL Server use, it's nice and fast). However I'd like to be...
4
by: Mike | last post by:
I have declared two classes. The first class has 4 private variables. Each has a property defined. I'm calling a readfile sub from a second class. The second class also has an Arraylist...
7
by: GaryDean | last post by:
I'm trying to load a GridView up with data manually, in code. I'm not using any datasource. Using this code.... ArrayList myRowArrayList; GridViewRow myGVR = new...
9
by: Scott Cupstid | last post by:
Ok, here it is. Which is more correct? AList = New ArrayList for i = 0 to 10 A = New myObject AList.Add(A) A = nothing next
1
by: BlouHond | last post by:
Hi, we have a VB.net assignment that is completely self study and it is proving quite difficult to do (Not an experienced VB programmer) The programme we have to write is object orientated (with...
1
by: JustinLee | last post by:
Hi, I have a small app that saves and loads data in XML format. Basically I have 2 methods. They each load data from a different XML documents. They both load data the same way. Everything works...
1
by: =?Utf-8?B?SkI=?= | last post by:
Hello My pgm1 (User Interface Level) passes an empty ArrayList to pgm2 (Business Logic Level). pgm2 then calls pgm3 (Data Access Level) to populate the ArrayList. Question1: When pgm2 gets...
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.