I have an xml that has levels and items. A level can contain an arbitrary number of items and any number of nested levels. Of course I need to define a special format for each level and possibly different formatting for items due to the level they are in. Is it possible to import such an xml into indesign? The xml would look something like this:
<xml>
<level>
<levelname>my level1</levelname>
<item>
<title>foo</title>
<someelements...></someelements>
</item>
<item>
<text>sometext</text>
</item>
<item ...>
</level>
<level>
<levelname>my level 2</levelname>
<level>
<levelname>my level 2.1</levelname>
<level>some deeper nesting</level>
<item>
<text>sometext</text>
</item>
<item>
<title>foo</title>
<someelements...></someelements>
</item>
<item ...>
</level>
<level...>
</level>
<level...>more levels</level>
</xml>
You can definitively import your XML within InDesign. You may need to understand some concepts to get repetition of your items like having parent nodes and using the "duplicate repeated text elements" in the XML import options. You will find soem tutorials over the net or with the great book from Jim Maivald : A Designer's Guide to Adobe InDesign and XML.
Other issue is styling. You can definitively link styles to tags but in your context any single item would get the same styling whatever it's hierarchy index. Your alternative is either to use aid:pstyle or aid:cstyle attributes within the structure, either use xslt to change nodes names given their position, or use scripting to apply the formatting.