Alexandre Takacs
asked on
XML newbie question - how to structure my files
Hello
I am starting a new project in which I have a create and the read XML files in VB.net
I am pretty much free to structure my files in which ever way I see fit. On the reading side I have to use the MSXML libraries / parser.
My file would tentatively have the following structure
etc
As such I have come up with
which will not parse correctly.
I'm sure this is an obvious newbie question but how should I structure my files ?
I am starting a new project in which I have a create and the read XML files in VB.net
I am pretty much free to structure my files in which ever way I see fit. On the reading side I have to use the MSXML libraries / parser.
My file would tentatively have the following structure
Item1
Property1
Property2
Item2
Property1
Property2
Property1
Property2
Item2
Property1
Property2
etc
As such I have come up with
<?xml version="1.0" encoding="UTF-8"?>
<item>
<itemnum>1</itemnum>
<property>
my property value
</property>
</item>
<item>
<itemnum>2</itemnum>
<property>
some other property value
</property>
</item>
which will not parse correctly.
I'm sure this is an obvious newbie question but how should I structure my files ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
From the processing point of view actually there is a general tendency to group similar elements in a container
it makes the processing easier
<?xml version="1.0" encoding="UTF-8"?>
<items>
<item>
<itemnum>1</itemnum>
<properties>
<property> my property value </property>
<property> my property value 2 </property>
</properties>
</item>
<item>
<itemnum>2</itemnum>
<properties>
<property> some other property value </property>
<property> some other property value 2</property>
</properties>
</item>
</items>
it makes the processing easier
correct, an XML document can only have one root element
ASKER
Thanks - things are starting to take shape...
I have another issue with the generated code where (I guess) the online editor I am using a playing some tricks on me. Say I have
<property> this is a test... </property>
it translates into
<property> this is a test … </property>
which will create a parsing error.
Again pretty sure these are minor and obvious gotchas but wondering how to avoid them...
I have another issue with the generated code where (I guess) the online editor I am using a playing some tricks on me. Say I have
<property> this is a test... </property>
it translates into
<property> this is a test … </property>
which will create a parsing error.
Again pretty sure these are minor and obvious gotchas but wondering how to avoid them...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok thanks - I think my most immediate questions have been answered :)
welcome... and good luck
ASKER