我試圖使用XPath謂詞拉了解析的XML文件的一部分,但不斷收到語法錯誤:運營商有望在特殊字符(如「/」和「@ 「)xpath查詢。當我用單引號包圍查詢時,它會失敗。運營商預計將在XPath查詢錯誤SwiProlog
?- load_xml_file('books.xml', DOM).
DOM = [element(book, [genre=romance], ['\n Gone With The Wind\n']), element(book, [genre=thriller], ['\n The Shining\n'])].
?- load_xml_file('books.xml', DOM), xpath(DOM, //book(@genre=thriller), Book).
ERROR: Syntax error: Operator expected
ERROR: load_xml_file('books.xml', DOM), xpath(DOM, //
ERROR: ** here **
ERROR: book(@genre=thriller), Book) .
?- load_xml_file('books.xml', DOM), xpath(DOM, '//book(@genre=thriller)', Book).
false.
的books.xml的內容:
<?xml version="1.0"?>
<book genre="romance">
Gone With The Wind
</book>
<book genre="thriller">
The Shining
</book>
叫你請張貼的books.xml呢? – 2012-03-14 08:36:45
我試過 '//書(@風格=驚悚片)', '//書'(@風格=驚悚片), '//書'( '@流派'=驚悚片)和 '//書'(」 @流派=驚悚')。這些都不會返回錯誤或錯誤。 – Clark 2012-03-14 12:30:19