Finding elements with XPath in Delphi

后端 未结 3 400
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-16 11:12

I am trying to find an element in an XML document in Delphi. I have this code, but it always says 0 elements in the log:

function TForm1.KannaSidu: Boolean;
         


        
3条回答
  •  耶瑟儿~
    2021-01-16 12:03

    If you're just trying to load a plain html file as xml, it would probably have multiple reasons to fail and choke on things like:

    
    

    You have to test that it actually loads correctly before doing anything else:

      if not Doc.load(filename) then
        raise Exception.Create('XML Loading error:' + Trim(Doc.parseError.reason));
    

    It will give you the specific reason for the failure like this one:

    XML Loading error:End tag 'head' does not match the start tag 'link'.
    

提交回复
热议问题