以下是一个xml格式:
<?xml version="1.0" encoding="GB2312" ?> 
 <wlfpML cnName="2010" name="wlfp2010s" version="wlfp2010" xsi:type="wlfp2010smb" xmlns="http://www.12366.ha.cn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
我新建一个空xml,把上面的加到xml中,用的是 xmlDocument控件,执行代码是:
OutXMLDoc.Active := true; //激活OutXMLDoc,自动初始化空的XML文档
  OutXMLDoc.Encoding := 'GB2312'; //设置字符集
  RootNode := OutXMLDoc.AddChild('wlfpML'); //建根结点
  RootNode.SetAttributeNS('cnName','','2010') ;
  RootNode.SetAttributeNS('Name','','wlfp2010s');
  RootNode.SetAttributeNS('version','','wlfp2010');
  //RootNode.SetAttributeNS('xsi:type','','wlfp2010smb');    //出错          
  RootNode.SetAttributeNS('xmlns','','http://www.12366.ha.cn');
  RootNode.SetAttributeNS('xmlns:xsi','','http://www.w3.org/2001/XMLSchema-instance');  出错提示:引用了未声明的名称空间前缀:xsi。
  请问 怎么修改, 谢谢! 在线等!  

解决方案 »

  1.   

    换一个XML解析器试试,即
    OutXMLDoc.DOMVendor := GetDOMVendor('Xerces XML');可能缺省的MSXML解析器不支持名称空间前缀。
      

  2.   

    excel表中节点属性名不能含有“:”
      

  3.   

    <?xml version="1.0" encoding="GB2312" ?>  
     <wlfpML cnName="2010" name="wlfp2010s" version="wlfp2010" xsi:type="wlfp2010smb" xmlns="http://www.12366.ha.cn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">这个 xml格式是 客户的一个接口 文档格式。
    “:” 在xml 为声明 命名空间, 不知道如何 在 delphi 中解析。期待 高手回答