delphi读取XML示例

procedure TfrmMain.btn1Click(Sender: TObject);
var
  TextXML:IXMLDocument;
  XmlRoot:IXMLNode;
  NodePos:IXMLNode;
  b:string;
  x,y:double;
  LocateInfo:TLocateInfo;
begin
  TextXML:=TXMLDocument.Create(nil);
  TextXML.LoadFromFile('c: esponse.xml');
  XmlRoot:= TextXML.DocumentElement;
  NodePos:=XmlRoot.ChildNodes['slia'].ChildNodes['pos'];
  LocateInfo.Mobile:=NodePos.ChildNodes['msid'].NodeValue;
  LocateInfo.X := NodePos.ChildNodes['pd'].ChildNodes['shape'].ChildNodes['Point'].ChildNodes['coord'].ChildNodes['X'].NodeValue;
  LocateInfo.Y := NodePos.ChildNodes['pd'].ChildNodes['shape'].ChildNodes['Point'].ChildNodes['coord'].ChildNodes['Y'].NodeValue;
  showmessage(b);
end;

  

 

//以下为示例XML文件:

 
     
         
	10587695901453864860     
     
         
	             
		13999991113             
		          
			                 
			      
				                         
					 
						116.21392                             
						40.22050                         
					                     
				   
			            
		         
	         
	M_NORMAL         
	010     
 

 

你可能感兴趣的:(delphi)