How can I use a XML file as a database and execute some basic SELECT command only on it !
ex: select author from file.xml where title=”MyTitle”
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
</book>
</catalog>
I’ve never worked with XML file (as DB) so have no code to put here, but hope someone have some solution !
You can look into XPath. The
System.XML.XmlDocument.SelectNodesmethod allows you to select matching nodes via XPath. It’s not SQL, but it’s a common way to find nodes in an XML document. The following example uses XPath to retrieve the authors of all the books with a title of “Midnight Rain”.