Dies ist die alte 4D Dokumentations-Website. Die neue und aktualisierte Dokumentation finden Sie unter developer.4d.com |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v20 R7
XML DECODE
|
XML DECODE ( xmlWert ; 4Dvar ) | ||||||||
Parameter | Typ | Beschreibung | ||||||
xmlWert | Text |
![]() |
Wert vom Typ Text, der aus einer XML Struktur stammt | |||||
4Dvar | Feld, Variable |
![]() |
4D Variable oder Feld für Empfang der konvertierten XML Werte | |||||
Der Befehl XML DECODE konvertiert einen Wert, gespeichert als ein XML String, in einen Wert vom Typ 4D. Die Konvertierung wird automatisch nach folgenden Regeln ausgeführt:
Wert | Beispiele | Konvertierung in englischem System |
Zahl | <Preis>8,5</Preis><Preis>8.5</Preis> | Zahl: 8.5 |
Boolean | <Doppel>1</Doppel> <Doppel>0</Doppel> | Boolean: True/False |
oder <Doppel>true</Doppel> <Doppel>false</Doppel> | ||
BLOB | Base64 Decodierung | |
Bild | Base64 Decodierung + BLOB zu Bildbefehl | |
Datum | 2009-10-25T01:03:20+01:00 | Löschen des Zeitteils und der Zeitzone: !25.10.2009! |
Zeit | 2009-10-25T01:03:20+01:00 | Löschen des Datumteils Warnung: Zeitzone wird berücksichtigt, wenn unterschiedlich zur lokalen Zeit. Beispiel: "2009-10-25T01:03:20+05:00" ergibt ?21:03:20? in lokaler Zeit UTC+1 |
Ist der Parametertyp 4Dvar nicht definiert, wird standardmäßig der Typ Text verwendet.
Daten aus einem XML Dokument importieren, in dem Werte als Attribute gespeichert sind.
Beispiel für XML Dokument:
<CD Date="2003-01-01T00:00:00Z" Description="This double CD reissued by EMI in 1995 combines 4 Stabat mater hymns. One by Rossini interpreted by the Berlin Symphony Orchestra, directed by Karl Forster. Followed by a work of Verdi, by the Philharmonic Orchestra, directed by Carlo Maria Giulini. On the second CD, you will find Francis Poulenc interpreted by Régine Crespin. This compilation ends with a little-known version, that of the Polish composer Karol Szymanowski. Polish National Radio Symphony Orchestra directed by Antoni Wit" Double="true" Duration="7246" Type="Sacred music" CD_ID="5" Performer="Various" Price="8.5" Title="4 Stabat mater"/>
Repeat
MyEvent:=SAX Get XML node(DocRef)
Case of
:(MyEvent=XML Start Element)
ARRAY TEXT(arrAttrNames;0)
ARRAY TEXT(arrAttrValues;0)
SAX GET XML ELEMENT(DocRef;vName;vPrefix;arrAttrNames;arrAttrValues)
If(vName="CD")
CREATE RECORD([CD])
For($i;1;Size of array(arrAttrNames))
$attrName:=arrAttrNames{$i}
Case of
:($attrName="CD_ID")
XML DECODE(arrAttrValues{$i};[CD]CD_ID)
:($attrName="Titel")
[CD]Work:=arrAttrValues{$i}
:($attrName="Preis")
XML DECODE(arrAttrValues{$i};[CD]Price)
:($attrName="Datum")
XML DECODE(arrAttrValues{$i};[CD]Date entered)
:($attrName="Dauer")
XML DECODE(arrAttrValues{$i};[CD]Total_duration)
:($attrName="Doppel")
XML DECODE(arrAttrValues{$i};[CD]Double_CD)
End case
End for
End if
...
End case
Until(MyEvent=XML End Document)
Produkt: 4D
Thema: XML
Nummer:
1091
Erstellt: 4D v12
4D Programmiersprache ( 4D v20 R7)