Re: XML element references/links.

From: Date: Wed, 28 Apr 2004 04:00:02 +0000
Subject: Re: XML element references/links.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-184825@lists.php.net to get a copy of this message
William Bailey wrote:
Hi,
    Im currently working with XML documents that have a lot of redundant data in them and am looking for a way to reference a already defined node from another node. How would one do this and how would this effect working with the xml document in php (DOM or simpleXML).
    So if i have something like the following....
<recording title="a song">
    <artist name="la la band, the"/>
    <tracks>
        <track name="track 01">
            <artist name="la la band, the"/>           </track>
        <track name="track 02">
            <artist name="la la band, the"/>           </track>
        <track name="track 03">
            <artist name="some other band"/>           </track>
        <track name="track 04">
            <artist name="la la band, the"/>           </track>
    </tracks>
    <media type="cd" release="20040101" deleted="20040201" catno="123abc">
        <label name="bad records">
            <address>
                <street>123 some street</street>
                <town>my town</town>
                <county>my county</county>
                <country>my country</country>
            </address>
            <distributor name="fast records">
                <address>
                    <street>456 some street</street>
                    <town>my town</town>
                    <county>my county</county>
                    <country>my country</country>
                </address>
            </distributor>
        </label>
    </media>
    <!-- .... List more media items with the same label/dist into repeated over and over again -->
</recording> Can i (for example) define the companies once and then put a reference to them where ever i want the information to go? Therefore reduceing the size of the XML document a lot (some recordings have 15+ media).
You can do something like this with an XML schema and a linkbase. If you're unfamiliar with those topics, start at the w3c's website and go read up on those topics. The ideas are somewhat similar to using a database, but be prepared to do a *lot* of reading.

« previous php.general (#184825) next »