This project has moved and is read-only. For the latest updates, please go here.
1
Vote

Wrong XPATH for <form><ul>

description

While trying to work with this HTML
<div class="liste clearfix">
    <form name="compare_products" id="compare_products" method="post" action="/compare_products">
        <ul>
                            <li class="protection">
    <a href="/safety-goggles/bolle-axis-2-clear">
        <div class="titre">
            <!-- gamme + modГЁle -->
            <h3 class="clearfix">
                <span>Safety</span>
                <strong>Safety Spectacles</strong>
            </h3>
            <!-- titre -->
            <p><strong>Axis 2</strong> Clear 1654101</p>
        </div>
        <!-- Photo -->
                    <img typeof="foaf:Image" src="http://www.bollesafety.com.au/sites/default/files/styles/top_produit/public/product_images/1085f6ba95ccc5ca5bf259268740731679680ee8/1654101-axis-2-clear.jpg?itok=TGeD3KNX" alt="" />                <!-- Sousbloc -->
        <div class="bloc">
            <p>
                <!-- SKU -->
                Ref.                1654101<br>
                <span>See this product</span>
            </p>
        </div>       
    </a>
    <!-- Comparer -->
    <div class="compare">
        <label for="compare-491">Compare this product</label>
        <input type="checkbox" class="checkbox compareProducts"
               id="compare-491"
               name="products[compare-491]"
               value="491" />
    </div>
</li>                            <li class="protection">
    <a href="/safety-goggles/bolle-axis-2-smoke">
        <div class="titre">
            <!-- gamme + modГЁle -->
            <h3 class="clearfix">
                <span>Safety</span>
                <strong>Safety Spectacles</strong>
            </h3>
            <!-- titre -->
            <p><strong>Axis 2</strong> Smoke 1654102</p>
        </div>
        <!-- Photo -->
                    <img typeof="foaf:Image" src="http://www.bollesafety.com.au/sites/default/files/styles/top_produit/public/product_images/3cfdf2f7c35f1668ca152b96fa45edd2a969f1c0/1654102-axis-2-smoke.jpg?itok=Vz-aObVK" alt="" />                <!-- Sousbloc -->
        <div class="bloc">
            <p>
                <!-- SKU -->
                Ref.                1654102<br>
                <span>See this product</span>
            </p>
        </div>       
    </a>
    <!-- Comparer -->
    <div class="compare">
        <label for="compare-492">Compare this product</label>
        <input type="checkbox" class="checkbox compareProducts"
               id="compare-492"
               name="products[compare-492]"
               value="492" />
    </div>
</li>                            <li class="protection">
    <a href="/safety-goggles/bolle-axis-2-contrast">
        <div class="titre">
            <!-- gamme + modГЁle -->
            <h3 class="clearfix">
                <span>Safety</span>
                <strong>Safety Spectacles</strong>
            </h3>
            <!-- titre -->
            <p><strong>Axis 2</strong> Contrast 1654118</p>
        </div>
        <!-- Photo -->
                    <img typeof="foaf:Image" src="http://www.bollesafety.com.au/sites/default/files/styles/top_produit/public/product_images/4d693492a6dfdbea3717204987580d99cf6f66d7/1654118-axis-2-contrast.jpg?itok=glIylp7f" alt="" />                <!-- Sousbloc -->
        <div class="bloc">
            <p>
                <!-- SKU -->
                Ref.                1654118<br>
                <span>See this product</span>
            </p>
        </div>       
    </a>
    <!-- Comparer -->
    <div class="compare">
        <label for="compare-493">Compare this product</label>
        <input type="checkbox" class="checkbox compareProducts"
               id="compare-493"
               name="products[compare-493]"
               value="493" />
    </div>
</li>                    </ul>
    </form>
</div>
this code:
doc.DocumentNode.SelectNodes("//form")
returns HtmlNode with no ChildNodes
so, XPATHs like "//form/ul" or "//form/ul/li" does not work at all.

comments