XMLPort loop question

jordi79
jordi79 Member Posts: 283

Hi,
How do you create xmlport for the following output —>

<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<Vendor>
<Name>Vendor Name for vendor 1</Name>
<Name>Vendor Name for vendor 2</Name>
<Name>Vendor Name for vendor 3</Name>
</Vendor>

The closest I could get is:

<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<Vendor>
<Name>Vendor Name for vendor 1</Name>
</Vendor>
<Vendor>
<Name>Vendor Name for vendor 2</Name>
</Vendor>
<Vendor>
<Name>Vendor Name for vendor 3</Name>
</Vendor>
<Vendor>
<Name>Vendor Name for vendor 4</Name>
</Vendor>

XMLport code in text (coded in c/al)

OBJECT XMLport 50000 test xml
{
OBJECT-PROPERTIES
{
Date=14-11-25;
Time=[ 2:31:43 PM];
Modified=Yes;
Version List=;
}
PROPERTIES
{
Direction=Export;
}
ELEMENTS
{
{ [{7563C036-F7A4-4DA9-838B-81AD0B2BEE0E}]; ;Vendors ;Element ;Table ;
SourceTable=Table23 }

{ [{5AE1BAC6-168F-4902-A426-01000B497630}];1 ;Name ;Element ;Field ;
DataType=Text;
SourceField=Vendor::Name }

}
EVENTS
{
}
REQUESTPAGE
{
PROPERTIES
{
}
CONTROLS
{
}
}
CODE
{

BEGIN
END.
}
}

Best Answer

  • jordi79
    jordi79 Member Posts: 283
    Answer ✓

    Not going to mention any names here…. but this was a requirement from am international bank. Actually, it was supposed to print description lines. So if the descripton lines exceed a certain length, then it's supposed to print the description on a new element.

    So far, the only way I can think to do this is to hardcode the xmlport to print a fixed no. of elements.

Answers

  • Miklos_Hollender
    Miklos_Hollender Member Posts: 1,623

    First this is not even valid XML, because it lacks a root node. You always need a root node, a text node, in this case you would use the XmlName "Vendor" or "Vendors", which solves half the problem.

    The other half I am not sure about: you need to suppress the TableElement somehow, exporting only the FieldElement. I don't know whether it is possible, maybe empty XMLName?

    You should also talk with whoever defined this requirement, because it is not a common, not a good XML structure IMHO. Good XML structures are not so flat. There is an element defining an entity (table), and under it, the properties of an entity (fields). Just a list of properties of different entities is IMHO not good XML.

  • jordi79
    jordi79 Member Posts: 283
    Answer ✓

    Not going to mention any names here…. but this was a requirement from am international bank. Actually, it was supposed to print description lines. So if the descripton lines exceed a certain length, then it's supposed to print the description on a new element.

    So far, the only way I can think to do this is to hardcode the xmlport to print a fixed no. of elements.