xml - Parse Delphi Project File on C# -
This may sound like a strange question, but for that I have my own reasons! I am trying to parse the Delphi 200 project file (.dprg), which is the XML representation of the project. I can load the document in an XmlDocument, but when I try and get the units used in this project, the selection nodes give me an empty list.
An example of this project is below:
& lt; Project xmlns = "http://schemas.microsoft.com/developer/msbuild/2003" & gt; ... ... & lt; Item group & gt; & Lt; Include Delphi Compiling = "Package.dpk" & gt; & Lt; Mainsource & gt; Mainsource & lt; / Mainsource & gt; & Lt; / DelphiCompile & gt; & Lt; In the context of the DCC include = "vcl.dcp" /> & Lt; Include in the context of DCC = "Unit 1 piece" / & gt; & Lt; In the context of the DCC = Include = "Unit 2." / & Gt; & Lt; In the context of DCC include = "Unit 3." / & Gt; & Lt; Include in the context of the DCC = "Unit4.pas" /> & Lt; Include in the context of DCC = "Unit 5 piece" /> ... & lt; / Item group & gt; & Lt; / Project & gt;
An example of the code is given below:
ProjectDocument.Load (FileName); XmlNodeList node list; XmlElement Routond = ProjectDocument.DocumentElement; String xmlns = RootNode.Attributes ["xmlns"]. Values; // It gives an empty list of nodalites = Routode Selection node ("/ Project / Item Group / DCCRferance"); Forresh (XMLNode title in node list) {console.lightline (title.indexml); } // Also gives an empty list nodelist = Routode. Select ("/ item group / DCCRferance"); Forresh (XMLNode title in node list) {console.lightline (title.indexml); }
The question is really, what am I doing wrong, because I should remember something. The only strange thing is that the document is not .xml, it's one. Dproj is
Therefore, thanks in advance if you can solve it.
Mark
quote:
< Strong> comment
If XPath expression requires a namespace resolution, then you should use the SelectNodes overload which takes it as its logic XmlNamespaceManager is used to resolve names.
Note If no prefix is included in XPath expression, it is assumed that Namespace URI is the empty namespace, if your XML contains a default namespace, then You still have to use XmlNamespaceManager and add a prefix and namespace url to it; Otherwise, you will not have any nodes selected.
You need it Also, note that there is no content in the nodes you select, so the InnerXML
property will be empty. Once you receive an empty list, your code will still be empty list of lines Will print.
Comments
Post a Comment