Note that there are some explanatory texts on larger screens.

plurals
  1. POParse Delphi Project File on C#
    text
    copied!<p>This may seem like an odd question, but I have my own reasons for this! I am trying to parse a Delphi 2009 project file (.dproj), which is an XML representation of the project. I Can load the document into an XmlDocument, but when I try and get to the units that are used in the project, SelectNodes gives me an empty list.</p> <p>An example of the project is below :</p> <pre><code>&lt;Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt; ... ... &lt;ItemGroup&gt; &lt;DelphiCompile Include="Package.dpk"&gt; &lt;MainSource&gt;MainSource&lt;/MainSource&gt; &lt;/DelphiCompile&gt; &lt;DCCReference Include="vcl.dcp"/&gt; &lt;DCCReference Include="Unit1.pas"/&gt; &lt;DCCReference Include="Unit2.pas"/&gt; &lt;DCCReference Include="Unit3.pas"/&gt; &lt;DCCReference Include="Unit4.pas"/&gt; &lt;DCCReference Include="Unit5.pas"/&gt; ... &lt;/ItemGroup&gt; &lt;/Project&gt; </code></pre> <p>An example of the code is below:</p> <pre><code> ProjectDocument.Load(FileName); XmlNodeList nodeList; XmlElement RootNode = ProjectDocument.DocumentElement; string xmlns = RootNode.Attributes["xmlns"].Value; // This gives an empty list nodeList = RootNode.SelectNodes("/Project/ItemGroup/DCCReference"); foreach (XmlNode title in nodeList) { Console.WriteLine(title.InnerXml); } // This also gives an empty list nodeList = RootNode.SelectNodes("/ItemGroup/DCCReference"); foreach (XmlNode title in nodeList) { Console.WriteLine(title.InnerXml); } </code></pre> <p>The question is really, what am I doing wrong, as I must be missing something. The only odd thing is that the document is not a .xml, it is a .dproj.</p> <p>So, thanks in advance if you can solve this.</p> <p>Mark</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload