Reputation: 11
I'm trying to scrape Pinterest using XPath and HTMLAgilityPack, but XPath writes ""
(//*(@id="XX"
) to represent the id attribute value, so in C# the strings are split and I get a syntax error. ("["@id="XX(error)"]"
) What should I do?
Upvotes: 1
Views: 502
Reputation: 111541
First, fix your XPath syntax error: Change //*(@id="XX"
to //*[@id="XX"]
.
Then, to represent //*[@id="XX"]
as a C# string, use either C# escaping or XPath alternative attribute value delimiters.
Escape the "
in C# via \"
"//*[@id=\"XX\"]"
or via verbatim string literal syntax
@"//*[@id=""XX""]"
Use '
as the attribute value delimiter, which both XML and XPath allow:
"//*[@id='XX']"
Upvotes: 1