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.
An example of the project is below :
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
...
<ItemGroup>
<DelphiCompile Include="Package.dpk">
<MainSource>MainSource</MainSource>
</DelphiCompile>
<DCCReference Include="vcl.dcp"/>
<DCCReference Include="Unit1.pas"/>
<DCCReference Include="Unit2.pas"/>
<DCCReference Include="Unit3.pas"/>
<DCCReference Include="Unit4.pas"/>
<DCCReference Include="Unit5.pas"/>
...
</ItemGroup>
</Project>
An example of the code is below:
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);
}
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.
So, thanks in advance if you can solve this.
Mark