Hi all,

I've been giving myself a crash course on XPath using XFactor Studios XPath
(AS2) in Flash and also with the XML Spy's built in XPath evaluator tool.
I'm still having some difficulty constructing some XPath expressions to best
fit my needs -- assuming that it can be done.

I'm working on a project that is a database of different document types for
various parts/products. The structure of the XML is...

<family ID="" label="">
        <group ID="" label="">
                <part ID="ABCDE" type="" partNo="" description="">
                        <document type="A" label="" file="ABCDE-A.pdf"/>
                        <document type="B" label="" file=""/>
                        <document type="C" label="" file=""/>
                        <document type="D" label="" file="ABCDE-docD.pdf"/>
                        <document type="E" label=""
file="installation.pdf"/>
                        <document type="F" label="" file=""/>
                        <document type="G" label="" file=""/>
                </part>
                <part ID="XYZ" type="" partNo="" description="">
                        <document type="A" label="" file="XYzee.pdf"/>
                        <document type="B" label="" file=""/>
                        <document type="C" label="" file=""/>
                        <document type="D" label="" file="ex2why.doc"/>
                        <document type="E" label=""
file="installation.pdf"/>
                        <document type="F" label="" file=""/>
                        <document type="G" label="" file=""/>
                </part>
        </group>
</family>       

There is no text in the elements. All data is presented as values of
attributes.

What I am trying to achieve is generating a new XML object based on specific
ID criteria and file attributes of document elements not being null.

For example, if I need all existing documents of parts that have "CD" in
their ID, the output XML object should be:

<family ID="" label="">
        <group ID="" label="">
                <part ID="ABCDE" type="" partNo="" description="">
                        <document type="A" label="" file="ABCDE-A.pdf"/>
                        <document type="D" label="" file="ABCDE-docD.pdf"/>
                        <document type="E" label=""
file="installation.pdf"/>
                </part>
        </group>
</family>       

I can select the part nodes based on criteria by using -- //part
[contains(@ID,\'HD2FB\')] -- which spits back an array of found <part>
elements and included child nodes. And, I can select documents where the
file attribute is not null by using -- //document [EMAIL PROTECTED] != ''] -- 
which
spits out the <document> elements. But, is it possible to get back the full
hierarchy based on selection criteria without having to reiterate and
rebuild the XML on the fly?

...Rob

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to