Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Anas Koara 1 post 21 karma points
    Feb 16, 2011 @ 18:05
    Anas Koara
    0

    find node ansectors

    Hi every body

    I am new heer and I want your help

    I have xml files

    <?xml version="1.0" encoding="utf-8"?>
    <Catalouges>
    <Catalouge ID="78" Name="a" Description="" ProductCount="305" ImagePath="\files\default\product\100\3.jpg">
    <SubCatalouge>
    <Catalouge ID="87" Name="b" ImagePath="/files/default/product/100/3.jpg" ProductCount="169">
    <SubCatalouge>
    <Catalouge ID="88" Name="c" ImagePath="/files/default/product/100/3.jpg" ProductCount="87" />
    <Catalouge ID="89" Name="d" ImagePath="/files/default/product/100/3.jpg" ProductCount="8" />
    <Catalouge ID="90" Name="e" ImagePath="/files/default/product/100/3.jpg" ProductCount="13" />
    <Catalouge ID="91" Name="f" Description="" ImagePath="/files/n_products/categories/200/137.jpg" ProductCount="53" />
    <Catalouge ID="440" Name="g" ImagePath="/files/default/product/100/3.jpg" ProductCount="8" />
    </SubCatalouge>
    </Catalouge>
    <Catalouge ID="172" Name="h" Description="" ImagePath="/files/default/product/100/3.jpg" ProductCount="16">
    <SubCatalouge>
    <Catalouge ID="173" Name="i" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="174" Name="j" ImagePath="/files/default/product/100/3.jpg" ProductCount="16" />
    <Catalouge ID="178" Name="k" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="179" Name="l" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="180" Name="m" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="181" Name="n" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="182" Name="o" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="183" Name="p" ImagePath="/files/default/product/100/3.jpg" ProductCount="0">
    <SubCatalouge>
    <Catalouge ID="184" Name="q" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="185" Name="r" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="186" Name="s" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    </SubCatalouge>
    </Catalouge>
    <Catalouge ID="191" Name="t" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    </SubCatalouge>
    </Catalouge>
    <Catalouge ID="187" Name="u" ImagePath="/files/default/product/100/3.jpg" ProductCount="15" />
    <Catalouge ID="189" Name="v" ImagePath="/files/default/product/100/3.jpg" ProductCount="32" />
    <Catalouge ID="192" Name="w" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="193" Name="c" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="197" Name="y" Description="" ImagePath="/files/default/product/100/3.jpg" ProductCount="18">
    <SubCatalouge>
    <Catalouge ID="171" Name="z" ImagePath="/files/default/product/100/3.jpg" ProductCount="0"/>

    <Catalouge ID="196" Name=" " ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="212" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="15" />
    <Catalouge ID="213" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="2" />
    <Catalouge ID="217" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="218" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="219" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="1">
    <SubCatalouge>
    <Catalouge ID="214" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="215" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="216" Name=" " ImagePath="/files/default/product/100/3.jpg" ProductCount="1" />
    <Catalouge ID="220" Name=" " Description="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="224" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="225" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="226" Name=" " ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    </SubCatalouge>
    </Catalouge>
    </SubCatalouge>
    </Catalouge>
    <Catalouge ID="198" Name="/ " ImagePath="/files/default/product/100/3.jpg" ProductCount="1" />
    <Catalouge ID="200" Name=" " ImagePath="/files/default/product/100/3.jpg" ProductCount="6">
    <SubCatalouge>
    <Catalouge ID="204" Name=" " ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="205" Name=" " ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="206" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="6" />
    </SubCatalouge>
    </Catalouge>
    <Catalouge ID="201" Name=" /" Description="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="202" Name=" " ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="209" Name=" " ImagePath="/files/default/product/100/3.jpg" ProductCount="18">
    <SubCatalouge>
    <Catalouge ID="190" Name=" " ImagePath="/files/default/product/100/3.jpg" ProductCount="2" />
    <Catalouge ID="195" Name=" " ImagePath="/files/default/product/100/3.jpg" ProductCount="1">
    <SubCatalouge>
    <Catalouge ID="234" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="235" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="236" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="237" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="1" />
    <Catalouge ID="238" Name=" " ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="239" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="240" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="241" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="242" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    </SubCatalouge>
    </Catalouge>
    <Catalouge ID="210" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="211" Name="/" ImagePath="/files/default/product/100/3.jpg" ProductCount="15" />
    <Catalouge ID="221" Name=" " ImagePath="/files/default/product/100/3.jpg" ProductCount="0">
    <SubCatalouge>
    <Catalouge ID="199" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    </SubCatalouge>
    </Catalouge>
    <Catalouge ID="222" Name=" " ImagePath="/files/default/product/100/3.jpg" ProductCount="0">
    <SubCatalouge>
    <Catalouge ID="227" Name=" " ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="228" Name=" " ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    </SubCatalouge>
    </Catalouge>
    <Catalouge ID="223" Name=" " ImagePath="/files/default/product/100/3.jpg" ProductCount="0">
    <SubCatalouge>
    <Catalouge ID="229" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="230" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="231" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="232" Name=" " ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="233" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    </SubCatalouge>
    </Catalouge>
    </SubCatalouge>
    </Catalouge>
    <Catalouge ID="310" Name=" " ImagePath="/files/default/product/100/3.jpg" ProductCount="0" />
    <Catalouge ID="439" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="28" />
    <Catalouge ID="445" Name="" ImagePath="/files/default/product/100/3.jpg" ProductCount="2" />
    </SubCatalouge>
    </Catalouge>

    </Catalouges>

     I and want to get the Catalouge node  with ID 186 and all its parents to use it in foreach

    <xsl:for-each select="//xsltexpersi">
    //out put @ID
    </xsl:for-each>

    can any body help me

    regards.

  • Rob Watkins 369 posts 701 karma points
    Feb 16, 2011 @ 19:23
    Rob Watkins
    0

    This works. I don't know if this is the most efficient way as I'm not an XSLT guru, but hopefully one will comment in horror if it's too bad!

    <xsl:template name="displayAncestry">
        <ul>
            <xsl:for-each select="//Catalouge[@ID = 186]/ancestor-or-self::Catalouge">
                <li><xsl:value-of select="@ID"/></li>
            </xsl:for-each>
        </ul>
    </xsl:template>
  • Rob Watkins 369 posts 701 karma points
    Feb 16, 2011 @ 19:24
    Rob Watkins
    0

    ...that will print it out as an HTML unordered list, obviously. Just remove the list tags if you just need the iterator - I kind of assumed you were building a breadcrumb trail :o)

Please Sign in or register to post replies

Write your reply to:

Draft