views:

11

answers:

0

Hi, I'm new to xml parsing and am trying to make a file for NSXMLParser to parse. I'd be editing it by hand and have several nested groups, so was looking for advice on how best to approach this.

I found that I couldn't just use newlines to cleanly separate my groupings because the newline would find its way into the parsed data. So, from what I've discovered so far, which of the following is my best option?

1) use some tool that makes viewing/editing xml docs visually easy? (suggestions?)

2) use newlines to separate and trim the newlines when I parse the data? Still not terribly readable:

<root>
<level1>
Data for Level 1
<level2>
Data for Level 2
<level3>
Data for Level 3
</level3>
</level2>
</level1>
</root> 

3) use newlines and tabs from within the tags like this:

<root><level1
>Data for Level 1<level2
    >Data for Level 2<level3
        >Data for Level 3</level3></level2></level1></root> 

Update: One thing I found works well for me. I just put the values for these 'levels' as attributes and tab each nested level.

<root>
    <level1 id="Data for Level 1">
        <level2 id="Data for Level 2">
            <level3 id="Data for Level 3">
                <level4 id="Data for Level 4a"></level4>
                <level4 id="Data for Level 4b"></level4>
                <level4 id="Data for Level 4c"></level4>
                <level4 id="Data for Level 4d"></level4>
            </level3>
        </level2>
    </level1>
</root> 

If anyone has any advice on whether there's any big issues with that, I'd love to hear. Thanks.