이것은 이상한 질문처럼 보일지 모르지만 나는 이것에 대한 내 자신의 이유가 있습니다! 프로젝트의 XML 표현 인 Delphi 2009 프로젝트 파일 (.dproj)을 파싱하려고합니다. 문서를 XmlDocument로로드 할 수 있지만 프로젝트에서 사용되는 단위를 가져 오면 SelectNodes에서 빈 목록을 제공합니다.C#에서 델파이 프로젝트 파일 구문 분석
프로젝트의 예는 다음과 같습니다
는<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>
코드의 예는 다음과 같습니다
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);
}
내가 누락해야하기 때문에 문제는 정말 어떻게 내가 잘못하고있는 중이 야한다
어떤 것. 유일하게 이상한 점은 문서가 .xml이 아니고 .dproj라는 점입니다.
이렇게 해결해 주시면 미리 감사드립니다.
마크
위의 두 가지 답변을 함께 사용하면 큰 도움이됩니다. 감사합니다. – Mmarquee