简体   繁体   中英

Html agility pack Addressing

in this Html

<div class="contacts-list">
    <h4 class="title">Contact</h4>
                <div class="contact-phone">
            <span class="icon"><i class="ee-phone"></i></span><span class="type">تلفن</span>
            <span class="contact-data">
                                        <a dir='auto' href='tel:05138946697'>05138946697</a>                                    </span>
        </div>

I have to extract the value of the "a" tag but I must be sure it is inside a "div" tag with a "contact-phone" class.

I don't really understand how I have to do this can someone help me?

so I get the value I need like this using the HTML Agility pack and Xpath

foreach (HtmlNode node in htmlDocument.DocumentNode.SelectNodes("//div[@class='" + "contact-phone" + "']/span[@class='"+ "contact-data" + "']/a"))
                        {
                            value = node.InnerText;
                        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM