⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmltree.pas

📁 httpanalyzer, source code for delphi
💻 PAS
字号:
  unit XmlTree;
  interface
  uses
    Variants, XMLIntf;

  function TreeView(XmlNode: IXMLNode; depth: Integer): AnsiString;

  implementation
  uses
    Tabs;

  function TreeView(XmlNode: IXMLNode; depth: Integer): AnsiString;
  var
    i: Integer;
    Attr: IXMLNode;
  begin
    Result := '';
    if XMLNode.NodeType = ntElement then
    begin
      if XmlNode.IsTextElement then
        if XmlNode.NodeValue <> null then
          Result := Tab[depth] +
            XmlNode.NodeName + ' = ' + XmlNode.NodeValue + CRLF
        else
          Result := Tab[depth] + XmlNode.NodeName + CRLF
      else
        if XmlNode.HasChildNodes then
          Result := Tab[depth] + '*' + XmlNode.NodeName + CRLF;

      for i:=0 to Pred(XmlNode.AttributeNodes.Count) do
      begin
        Attr := XmlNode.AttributeNodes[i];
        Result := Result + Tab[depth+1] +
          '[' + Attr.NodeName + ' = ' + Attr.NodeValue + ']' + CRLF
      end;
      if XmlNode.HasChildNodes then
        for i:=0 to Pred(XmlNode.ChildNodes.Count) do
          Result := Result + TreeView(XmlNode.ChildNodes[i], depth+1)
    end
  end {TreeView};

  end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -