Link to home
Start Free TrialLog in
Avatar of Alexandre Takacs
Alexandre TakacsFlag for Switzerland

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

Item1
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>

Open in new window


which will not parse correctly.

I'm sure this is an obvious newbie question but how should I structure my files ?
SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Alexandre Takacs

ASKER

aha - gotcha - so you always need a "root" node and after that you can go about your merry way :) ?
From the processing point of view actually there is a general tendency to group similar elements in a container

<?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>

Open in new window


it makes the processing easier
correct, an XML document can only have one root element
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 &hellip; </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
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok thanks - I think my most immediate questions have been answered :)
welcome... and good luck