據我所知,我可以用Sql語法搜索DB %like%
。如何處理XML字符串%Like%search in C#
現在我正在使用XML,如何處理C#中XML文件的相同搜索條件?
我想搜索字符串並找到關鍵字的一部分。不是關鍵字的全文。
<bookstore>
<book genre="autobiography">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
<book genre="philosophy">
<title>The Gorgias</title>
<author>
<name>Plato</name>
</author>
<price>9.99</price>
</book>
</bookstore>
假設我正在使用上面的示例XML。如何在C#中編碼以搜索「%jami%」,然後返回「Benjamin」。謝謝。
謝謝。我找到了關於String.Containers()的示例代碼。根據我的需要,它工作得很好。 – 2010-05-21 05:40:29
這會起作用,但Garett對XPath或Linq To XML的建議是更優雅的方法。 – allonym 2010-05-21 08:51:11