XML Help: How should I structure it?

I’m trying to get all the text in a webpage into an XML file. I’ve decided to break the page into "sections" which can contain "headers" and "bodies" which contain the majority of information. Is this too repetitive? Is there a better way? Thanks.

<text language = "english">
<sections>
<section id="header">
<header>Read</header>
</section>
<section id="select_language">
<header>Select Language:</header>
<bodies>
<body>English</body>
<body>Spanish</body>
<body>Mandarin</body>
<body>Hindi</body>
</bodies>
</section>
</sections>
</text>
My main concern is with the repeating <body> tags and if it’s okay to have a lot of <sections> with different content within each.


One Response to “XML Help: How should I structure it?”

  • JakeCigar:

    structuring xml is an iterative process.

    You’ll want to have sets of tags for each language

    <body lang="en"> Hello, I am English </body>
    <body lang="es"> Hola, soy Español </body>

    or mix in
    <body>
    <greet lang="en"> Hello </greet>
    <greet lang="es"> Hola </greet>
    </body>

    or keep each language as a separate file.

    Just don’t write too many XML files until you know which format you want! Though you can always use XSL to rewrite your XML.

    UPDATE: It’s xml, not html, you can have as many body tags as you want! When you need to display as html, you may want to generate 1 file with all the languages or different files for each language.

Leave a Reply