title: XPath not working correctly with XFA
body: <p>I have a dynamic PDF form that has a DropDownList. I'm using iTextSharp to try and modify the values inside the PDF before sending it out to the client. Here's what I'm trying, as per an answer in <a href="https://stackoverflow.com/questions/8990235/c-sharp-to-read-xfa-form-data">this question</a>:</p>
  
  <pre><code>PdfReader reader = new PdfReader(myPdfPath);
  XmlDocument xdoc = reader.AcroFields.Xfa.DomDocument;
  XmlNode dropdown = xdoc.SelectSingleNode("/*/template/subform[@name='form1']/subform[@name='form2']/field[@name='DropDownList1']");
  </code></pre>
  
  <p>But no matter what XPath expression I use (ex: <code>//subform</code> or <code>field[@name='DropDownList1']</code>), <code>SelectSingleNode</code> always returns <code>null</code>, and <code>SelectNodes</code> returns an empty list.</p>
  
  <p>Am I doing something wrong here? If there is a better way of doing this, I'd love to know.</p>
  
  <p>Here's some the xml (I want the field node):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/" timeStamp="2013-01-18T13:22:31Z" uuid="3c6141a4-56b4-4f6e-8a2d-4519050f1c69"&gt;  
  
  &lt;template xmlns="http://www.xfa.org/schema/xfa-template/3.0/"&gt;  
  &lt;?formServer defaultPDFRenderFormat acrobat9.1dynamic?&gt;  
      &lt;subform name="form1" layout="tb" locale="en_US" restoreState="auto"&gt; 
          &lt;pageSet&gt; 
              &lt;pageArea name="Page1" id="Page1"&gt; 
                  &lt;contentArea x="0.25in" y="0.25in" w="576pt" h="756pt"/&gt;  
                  &lt;medium stock="default" short="612pt" long="792pt"/&gt;  &lt;?templateDesigner expand 0?&gt; 
              &lt;/pageArea&gt;
              &lt;?templateDesigner expand 0?&gt; 
          &lt;/pageSet&gt;  
          &lt;subform w="576pt" h="756pt" name="form2"&gt; 
              &lt;field name="DropDownList1" y="22.225mm" x="6.35mm" w="62mm" h="9mm"&gt; 
                  &lt;ui&gt; 
                      &lt;choiceList&gt; 
                          &lt;border&gt; 
                              &lt;edge stroke="lowered"/&gt; 
                          &lt;/border&gt;  
                          &lt;margin/&gt; 
                      &lt;/choiceList&gt; 
                  &lt;/ui&gt;  
                  &lt;font typeface="Myriad Pro"/&gt;  
                  &lt;margin topInset="1mm" bottomInset="1mm" leftInset="1mm" rightInset="1mm"/&gt;  
                  &lt;para vAlign="middle"/&gt;  
                  &lt;caption reserve="25mm"&gt; 
                      &lt;para vAlign="middle"/&gt;  
                      &lt;value&gt; 
                          &lt;text&gt;Drop-down List&lt;/text&gt; 
                      &lt;/value&gt; 
                  &lt;/caption&gt;  
                  &lt;items save="1"&gt; 
                      &lt;text&gt;Item 1&lt;/text&gt;  
                      &lt;text&gt;Item 2&lt;/text&gt;  
                      &lt;text&gt;Item 3&lt;/text&gt; 
                  &lt;/items&gt; 
              &lt;/field&gt;  
          &lt;/subform&gt;  
          &lt;proto/&gt;  
          &lt;desc&gt; 
              &lt;text name="version"&gt;10.0.2.20120224.1.869952.867557&lt;/text&gt; 
          &lt;/desc&gt;
          &lt;?templateDesigner expand 1?&gt;
          &lt;?renderCache.subset "Myriad Pro" 0 0 ISO-8859-1 4 112 28 0001000E001200130023002400250027002D0033003500420044004500460049004A004C004D004F00500051005300540055005600580059 -12BCDFLRTacdehiklnoprstuwx?&gt;
      &lt;/subform&gt;  
      &lt;?templateDesigner DefaultPreviewDynamic 1?&gt;
      &lt;?templateDesigner DefaultRunAt client?&gt;
      &lt;?templateDesigner Grid show:1, snap:1, units:0, color:ff8080, origin:(0,0), interval:(125000,125000)?&gt;
      &lt;?templateDesigner DefaultCaptionFontSettings face:Myriad Pro;size:10;weight:normal;style:normal?&gt;
      &lt;?templateDesigner DefaultValueFontSettings face:Myriad Pro;size:10;weight:normal;style:normal?&gt;
      &lt;?templateDesigner DefaultLanguage JavaScript?&gt;
      &lt;?acrobat JavaScript strictScoping?&gt;
      &lt;?templateDesigner WidowOrphanControl 0?&gt;
      &lt;?templateDesigner SaveTaggedPDF 1?&gt;
      &lt;?templateDesigner SavePDFWithEmbeddedFonts 1?&gt;
      &lt;?templateDesigner FormTargetVersion 30?&gt;
      &lt;?templateDesigner Rulers horizontal:1, vertical:1, guidelines:1, crosshairs:0?&gt;
      &lt;?templateDesigner Zoom 92?&gt;
  &lt;/template&gt;  
  &lt;xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve"&gt;
      &lt;annots/&gt;
  &lt;/xfdf&gt;
  &lt;datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"&gt;&lt;/datasets&gt;
  &lt;/xdp:xdp&gt;
  </code></pre>