c# and xml search

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<span>Hello!
I have been working on a C# program that searches for a record in an Xml file and then outputs the query results.  I can get it to work with one search keyword, but I want to be able to do a search with two or three search keywords also.  There is something wrong with the strExpression.  It doesnt work when I try to put that "and" in there.  Can someone help me fix my string statement?  "book" and "author" are text from textboxes.
Here is Part of my Xml:
<font color="#008000 <ROW>
  <BOOKID>B00018</BOOKID>
  <BOOK>HARRY POTTER2</BOOK>
  <PUBLISHERNAME>ARTHUR A. LEVINE BOOKS</PUBLISHERNAME>
  <AUTHORNAMEKANA>ROWLING</AUTHORNAMEKANA>
  <AUTHORNAMEKANJI>ROWLING</AUTHORNAMEKANJI>
  <PRICE>1   </PRICE>
  <DELETEFLG>0</DELETEFLG>
  <REGDT>20060712</REGDT>
  <REGTM>095508</REGTM>
  <UPDDT>20060720</UPDDT>
  <UPDTM>172549</UPDTM>
 </ROW></font>
Here is part of my program:
<font style="background-color:#ffffff" color="#800000 string strExpression=null;</font>
<font style="background-color:#ffffff" color="#800000             if (publisher == "")
            {
                <font style="background-color:#ccffff strExpression = "//BOOKID [BOOK = " + book + " and AUTHORNAMEKANJI = " + author + "]/following-sibling::* ";</font></font><font style="background-color:#ffffff" color="#800000
            }
            </font>
<font style="background-color:#ffffff" color="#800000  XmlDataDocument xDoc = new XmlDataDocument();
            xDoc.Load("practice.xml");
            XmlNodeList xmn = xDoc.SelectNodes(strExpression);</font>



View the full article
 
Back
Top