title: Warning: DOMXPath::evaluate() [domxpath.evaluate]: Invalid expression
body: <p>When my $keyword input string in the function below contains double quotes...</p>
  
  <blockquote>
    <p>'this is a "test" for example'</p>
  </blockquote>
  
  <p>I'm getting this error:</p>
  
  <blockquote>
    <p>Warning: DOMXPath::evaluate()
    [domxpath.evaluate]: Invalid
    expression</p>
  </blockquote>
  
  <p>It occurs on the line just below the one commented below "ERROR OCCURS" on the xpath->evaluate method.</p>
  
  <pre><code>function my_function($heading, $post){
      $content = $post-&gt;post_content;
      if($content=="" || !class_exists('DOMDocument')) return false;
      $keyword = trim(strtolower(my_getKeyword($post)));
      @$dom = new DOMDocument;
      @$dom-&gt;loadHTML(strtolower($post-&gt;post_content));
      $xPath = new DOMXPath(@$dom);
      switch ($heading)
          {//ERROR OCCURS
          case "img-alt": return $xPath-&gt;evaluate('boolean(//img[contains(@alt, "'.$keyword.'")])');
          default: return $xPath-&gt;evaluate('boolean(/html/body//'.$heading.'[contains(.,"'.$keyword.'")])');
          }
  }
  
  
  function my_getKeyword($post)
  {
      $myKeyword = get_post_meta($post-&gt;ID, '_my_keyword', true);
  
      if($myKeyword == "") $myKeyword = $post-&gt;post_title;
  
      return " ".$myKeyword;
  }
  </code></pre>