AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein XML Delphi Wie in MSXML Kommentare ignorieren?
Thema durchsuchen
Ansicht
Themen-Optionen

Wie in MSXML Kommentare ignorieren?

Ein Thema von jus · begonnen am 22. Aug 2015 · letzter Beitrag vom 24. Aug 2015
 
Der schöne Günther

Registriert seit: 6. Mär 2013
6.191 Beiträge
 
Delphi 10 Seattle Enterprise
 
#5

AW: Wie in MSXML Kommentare ignorieren?

  Alt 24. Aug 2015, 09:26
Ein Knoten hat die Eigenschaft NodeType. Und wenn dieser NodeType = TNodeType.ntComment ist, dann ist der Knoten ein Kommentar.

Delphi-Quellcode:
program Project5;

{$APPTYPE CONSOLE}

{$R *.res}

uses
   System.SysUtils,
   WinApi.ActiveX,
   Xml.XmlIntf, Xml.XmlDoc
;

procedure justXmlThings();
const
   xmlContent = '<root><node1/><!-- this is a comment --><node2/></root>';
var
   nodes:      IXMLNodeList;
   nodeIndex:   Integer;
   node:      IXmlNode;
begin
   nodes := LoadXMLData(xmlContent).DocumentElement.ChildNodes;
   for nodeIndex := 0 to Pred(nodes.Count) do begin
      node := nodes.Get(nodeIndex);
      if (node.NodeType <> TNodeType.ntComment) then
         WriteLn(node.NodeName);
   end;
end;

begin
  try
   CoInitializeEx(nil, COINIT_APARTMENTTHREADED);
   try
      justXmlThings();
   finally
      CoUninitialize();
    end;
  except
   on E: Exception do
     Writeln(E.ClassName, ': ', E.Message);
  end;
  WriteLn('end.'); readln;
end.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:40 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz