小编Kon*_*zev的帖子

MSHTML无效解析ARTICLE标记

我正在尝试通过Delphi 10 Seattle中的MSHTML解析器解析HTML.它运行正常,但是ARTICLE标签混淆了它,解析了ARTICLE元素没有innerHTML和children,尽管它们在那里.

    program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils,
  Variants,
  ActiveX,
  MSHTML;

procedure DoParse;
var
  idoc: IHTMLDocument2;
  iCollection: IHTMLElementCollection;
  iElement: IHTMLElement;
  V: OleVariant;
  HTML: String;
  i: Integer;
begin
  Html :=
    '<html>'#10+
    '<head>'#10+
    '    <title>Articles</title>'#10+
    '</head>'#10+
    '<body>'#10+
    '    <article>'#10+
    '        <p>This is my Article</p>'#10+
    '    </article>'#10+
    '</body>'#10+
    '</html>';


  v := VarArrayCreate( [0,1], varVariant);
  v[0]:= Html;

  idoc := CoHTMLDocument.Create as IHTMLDocument2;
  idoc.designMode := 'on';
  idoc.write(PSafeArray(System.TVarData(v).VArray));
  idoc.close;

  iCollection := idoc.all as IHTMLElementCollection;
  for i := 0 to iCollection.length-1 do
  begin
    iElement …
Run Code Online (Sandbox Code Playgroud)

html delphi parsing mshtml

6
推荐指数
1
解决办法
343
查看次数

标签 统计

delphi ×1

html ×1

mshtml ×1

parsing ×1