我用XMLDocument来解析XML文件没有问题,文件的基本格式是这样的: 
<?xml version="1.0" encoding="UTF-8"? > 
<OETest name="36" type="22" > 
   <option content="parent1" > 
     <item id="55" text="测试1" > </item > 
     <item id="56" text="测试2" > </item > 
   </option > 
   <option content="parent1" > 
     <item id="4" text="考试" > </item > 
   </option > 
</OETest > 
但是,现在我收到的是XML字符串,就是把上面的内容拼成串,这样的话我把XMLDocument.XML.Text赋值成这个串就解析不出来了,找不到结点了好像,请教各位这是怎么回事?或者有其他方法可以解决这个问题吗?着急啊,解决了就结贴!!!谢谢~~ 
串是这样的: <?xml version="1.0" encoding="UTF-8"? > <OETest name="36" type="22" > <option content="parent1" > <item id="55" text="测试1" > </item > <item id="56" text="测试2" > </item > </option > <option content="parent1" > <item id="4" text="考试" > </item > </option > </OETest >

解决方案 »

  1.   

    直接赋值可能有问题,你可以考虑先将串保存成临时XML文档,再用XMLDocument读取。。
      

  2.   

    我LoadFromXML()也不行,真是郁闷,保存也不行啊,应该有好的解决方案吧,大家快来帮帮忙吧~~
      

  3.   

    不对呀,按你这个:
    <?xml version="1.0" encoding="UTF-8"?  >  
    <OETest name="36" type="22"  >  
        <option content="parent1"  >  
          <item id="55" text="测试1"  >  </item  >  
          <item id="56" text="测试2"  >  </item  >  
        </option  >  
        <option content="parent1"  >  
          <item id="4" text="考试"  >  </item  >  
        </option  >  
    </OETest  >  
    保存后,可以读取出的呀。。
      

  4.   

    多半是没有模板文件,你先创建一个空的xml文件,然后参考下面:  AXmlF:= 'c:\Test.xml '; 
     if FileExists(AXmlF) then 
      begin 
        try 
          list:= TStringList.Create; 
          list.Append( ' <?xml version="1.0" encoding="GB2312"? > '); 
          list.Append( ' <OETest name="36" type="22"  > '); 
          list.Append( ' <option content="parent1"  > '); 
          list.Append( '                <desc > '); 
          //list.Append( '                        <archivesID > '+ID+ ' </archivesID > '); 
          //list.Append( '                        <archivesDesc > '+Name+ ' </archivesDesc > '); 
          //list.Append( '                        <archFlag >1 </archFlag > '); 
          list.Append( '                </desc > '); 
          list.Append( ' </archives > '); 
          list.Append( ' </cgrsArchives > '); 
          list.SaveToFile(AXmlF);   //Savepath+ '\CGAMS_FILE_ '+Name+ '.xml ' 
        finally 
          list.Free; 
        end; 
      end 
      else 
      begin 
         showmessage( '指定文件 '+AXmlF+ '不存在! '); 
         exit; 
      end; 
      

  5.   

    如果结构固定的话,可以用XML Data Bing