I am trying to parse either XML or JSON (doesn't matter, the API I'm interested in provides both) in Delphi Prism but all Tutorials and Howto开发者_如何学运维s show the Delphi code which is no longer available in Prism.
Could you please help me?
(I'm not trying to compile Prism code from XML, I'm trying to parse XML in Prism ^^)
Pretty easy really. Make sure you have a framework version 3.5 and above version of a new project. Then you have two choices, if you have an XSD you can create classes from xml. You can do this with the XSD.EXE tool (/language:Oxygene). If you want to parse any xml, you can use the XDocument class defined in the System.Xml.Linq namespace:
var lDoc := new XDocument();
lDoc.Load(streamorfile);
var lAllTextValuesInNodeNameNodes := from x in lDoc.Elements where x.Name = 'nodename' select x.Value;
精彩评论