Hi,
I am currently tearing my hair out trying to figure out how to effectivly parse a set of XML data I have in to an Arraylist of Custom Objects. I am unsure of the best method, whether to use Xpath or XMLreader.
My full XML data can be seen at http://pastebin.com/m393c25 however this is a snippet of XML data for example:
My object structure:
I am just simply creating them in my method as
And I want to add each block of XML <data> into my object using, for example, a simple:
However I am having massive problems actually traversing my XML and getting the right data from the right places and putting it into the object so each block of <data> becomes an object and is added onto the Arraylist. I was previously using an 2 dimensional array however this was incredibly messy, crude and not very adaptable. If you wish to see this code it is viewable at http://pastebin.com/d496ef501.
If anyone can offer any assistance in solving my problem of taking XML data and dumping it into an object it would be much appreciated.
I am currently tearing my hair out trying to figure out how to effectivly parse a set of XML data I have in to an Arraylist of Custom Objects. I am unsure of the best method, whether to use Xpath or XMLreader.
My full XML data can be seen at http://pastebin.com/m393c25 however this is a snippet of XML data for example:
Code:
<config> <authority sfile="testdata.csv" id="3"> <data> <name>title</name> <item1>2</item1> <exp>^([A-Z]*/)?(EPF/)?[0-9]{4}/[0-9]{2}$</exp> </data> <data> <name>location</name> <item1>3</item1> <exp></exp> </data> </authority> <config>
Code:
Private Structure xmlStruct Public name As String Public column As Integer Public expression As String End Structure
Code:
Dim xmlList As New ArrayList Dim xmlObj As xmlStruct
Code:
With xmlObj .name = strNameValue .column = strItem1Value .expression = strExpValue End With xmlList.Add(xmlObj)
If anyone can offer any assistance in solving my problem of taking XML data and dumping it into an object it would be much appreciated.
Comment