AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

xml Nodes Attribute lesen

Ein Thema von Pfaffe · begonnen am 20. Sep 2022 · letzter Beitrag vom 20. Sep 2022
Antwort Antwort
Pfaffe

Registriert seit: 29. Jan 2009
294 Beiträge
 
Delphi 12 Athens
 
#1

xml Nodes Attribute lesen

  Alt 20. Sep 2022, 07:02
Ich habe eine BMECAT xml und möchte per TXMLDocument PRICE_FLAG lesen.
Mit s:= LNodeElement_CATALOG.ChildNodes.FindNode('PRICE_FL AG').Text; komme ich an das erste PRICE_FLAG, welches "false" ist.
Mit s:= LNodeElement_CATALOG.ChildNodes.FindNode('PRICE_FL AG').AttributeNodes['type'].Text; komme ich an das erste Attribut, welches "incl_assurance" lautet.
Wie aber komme ich an die weiteren drei PRICE_FLAG's?

<?xml version="1.0" encoding="UTF-8"?>
<BMECAT version="2005">
<HEADER>
<CATALOG>
<LANGUAGE>deu</LANGUAGE>
<CATALOG_ID>2021</CATALOG_ID>
<CATALOG_VERSION>09</CATALOG_VERSION>
<CATALOG_NAME>Produktkatalog</CATALOG_NAME>
<TERRITORY>DE</TERRITORY>
<CURRENCY>EUR</CURRENCY>
<PRICE_FLAG type="incl_assurance">false</PRICE_FLAG>
<PRICE_FLAG type="incl_duty">true</PRICE_FLAG>
<PRICE_FLAG type="incl_packing">false</PRICE_FLAG>
<PRICE_FLAG type="incl_freight">false</PRICE_FLAG>
</CATALOG>
  Mit Zitat antworten Zitat
bcvs

Registriert seit: 16. Jun 2011
668 Beiträge
 
Delphi 12 Athens
 
#2

AW: xml Nodes Attribute lesen

  Alt 20. Sep 2022, 07:30
Ich würde das anders angehen und durch die Nodes iterieren:
Delphi-Quellcode:
var Node:IXMLNode;

Node:= LNodeElement_CATALOG.ChildNodes.First;
while Node<>nil do
begin
  if Node.NodeName = 'PRICE_FLAGthen
  begin
    if Node.Attributes['type'] = 'incl_assurancethen
      ...
    else if Node.Attributes['type'] = 'incl_dutythen
      ...
  end;
  Node := Node.NextSibling;
end;
(nicht getestet)
  Mit Zitat antworten Zitat
Pfaffe

Registriert seit: 29. Jan 2009
294 Beiträge
 
Delphi 12 Athens
 
#3

AW: xml Nodes Attribute lesen

  Alt 20. Sep 2022, 08:03
Danke, funktioniert.
  Mit Zitat antworten Zitat
Antwort Antwort


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 10:43 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz