PDA

Ver la Versión Completa : Etiquetas XML


Angel.Matilla
14-01-2015, 12:02:26
Como muchos yo también estoy dándole vueltas al tema de los mandatos SEPA. Me he econtrado en el manual de la AEB para estos soportes (https://www.aebanca.es/cs/groups/public/documents/folletos/folleto-201305190.pdf), en la página 38 hay esto:
2.44 Importe ordenado – InstructedAmount
* Definición: Importe del adeudo directo expresado en euros (AT-06).
* Etiqueta XML: <InstdAmt>
* Ocurrencias: [1..1]
* Formato:
ActiveOrHistoricCurrencyAndAmount: FractionDigits: 2, minInclusive: 0, totalDigits: 11
ActiveOrHistoricCurrencyCode: [A-Z]{3,3}* Reglas de uso:
Máximo 11 dígitos, de los cuales 2 son decimales (importe mínimo: 0.01, importe máximo: 999999999.99).
Separador decimal: '.'.
En la etiqueta debe incluirse el código 'EUR' correspondiente a la moneda euro, según la ISO 4217.
Ejemplo: Adeudo directo de 537 euros
<InstdAmt Ccy="EUR">537.00</InstdAmt> ¿Cómo hago para insertar en la etiqueta InstdAmt ese valor Ccy="EUR"? Estoy trabajando con Builder 6.

Neftali [Germán.Estévez]
14-01-2015, 15:48:24
Un código como este:


var
Items, Task: IXMLNode;
XML:string;
Doc: IXMLDocument;
begin

Doc := NewXMLDocument;
Items := Doc.AddChild('CdtTrfTxInf');
//...
Items := Items.AddChild('amt');
Task := Items.AddChild('InstdAmt');
Task.Attributes['Ccy'] := 'EUR';
Task.NodeValue := '537.00';
//...
XML := Doc.XML.Text;
Memo1.Lines.Text := XML;


Te dará un resultado como este:


<?xml version="1.0"?>
<CdtTrfTxInf>
<amt>
<InstdAmt Ccy="EUR">537.00</InstdAmt>
</amt>
</CdtTrfTxInf>

Angel.Matilla
14-01-2015, 18:44:19
Gracias por la respuesta. El código que tengo ahora es este (decartando las cabeceras del formato SEPA):
_di_IXMLNode iNode0, iNode1, iNode2, iNode3, iNode4, iNode5, iNode6, iNode7;

XMLDocument1->Active = false;
XMLDocument1->FileName = "";
XMLDocument1->Active = true;

XMLDocument1->DocumentElement = XMLDocument1->CreateElement("Document","urn:iso:std:iso:20022:tech:xsd:pain.008.001.02");
[...]
iNode2 = iNode1->AddChild(WideString("DrctDbtTxInf"));
iNode3 = iNode2->AddChild(WideString("PmtId"));
iNode4 = iNode3->AddChild(WideString("EndToEndId"));
iNode4->SetNodeValue(fSelSoc->Lista->Items->Item[nItem]->SubItems->Strings[1]);
iNode3 = iNode2->AddChild(WideString("InstdAmt"));
iNode3->Attributes["Ccy"] = "EUR";
iNode3->SetNodeValue(StringReplace(StringReplace(Lista->Items->Item[nItem]->SubItems->Strings[4], "€", "", oReplace), ",", ".", oReplace));Al grabar el fichero lo hace así:
<DrctDbtTxInf>
<PmtId>
<EndToEndId>4160</EndToEndId>
</PmtId>
<InstdAmt Ccy="True"/>
</DrctDbtTxInf>Compila bien, pero al ejecutar me da esete error en línea SetNodeValue:
http://i98.photobucket.com/albums/l251/Angel_Matilla/Error_zps3c51fb88.jpg (http://i98.photobucket.com/albums/l251/Angel_Matilla/Error_zps3c51fb88.jpg)
Va pro delante: Parte de los datos los saco de un TListView que está en un formulario que sigue abierto.

Angel.Matilla
14-01-2015, 19:42:28
Perdón. Me equivoqué en el código. Tengo puesto esto:
iNode3 = iNode2->AddChild(WideString("InstdAmt"));
iNode3->Attributes["Ccy"] = "EUR";
iNode3->NodeValue = StringReplace(StringReplace(fSelSoc->Lista->Items->Item[nItem]->SubItems->Strings[4], "€", "", oReplace), ",", ".", oReplace).Trim();y en lugar de EUR me pone True.
<InstdAmt Ccy="True">24.00</InstdAmt>

Neftali [Germán.Estévez]
14-01-2015, 22:02:38
¿Sólo por curiosidad y para descartar, si pones cualquier otra cosa, qué aparece?


iNode3->Attributes["Ccy"] = "clubdelphi";

Angel.Matilla
15-01-2015, 10:09:01
¿Sólohttp://cdncache-a.akamaihd.net/items/it/img/arrow-10x10.png (http://www.clubdelphi.com/foros/#) por curiosidad y para descartar, si pones cualquier otra cosa, qué aparece?
Lo mismo: True.

Angel.Matilla
16-01-2015, 10:37:37
Lo que me está pasando ¿Puede tener algo que ver con las propiedades del componente TXMLDocument?