Official Content

Converts the data stored in a variable into an XML structure with a Tag for each Transaction attribute. For each Transaction attribute, a Tag_Z will be created with its old value.


&VarStr = &VarBasedOnBC.ToXml()


     Is a variable defined in a GeneXus object based on the character data type.

      Is a variable defined in a GeneXus object, based on a Business Component.


Suppose you define the following Transaction as Business Component (by setting its Business Component property = True):

  CustomerId*     (Autonumber property = True)

Customer rule:


Accordingly, a Business Component data type of the Customer Transaction is automatically created in the Knowledge Base and you can define a variable of the new type created in any object.

Thus, in any Web Panel object you can define a variable named &Customer based on the Customer type. 

The objective of the Web Panel is to allow the user to enter a customer Id value. Then, by pressing a button, the Event associated with the button will load in memory (in the &Customer Business Component variable) the customer data stored in the database associated with the customer id entered by the user. Next, the ToXml method will be applied to the &Customer variable, to convert the customer data to an XML format and it will be shown in the Web Panel Web Layout.

To achieve this, you will also have to define these variables in the Web Panel: 

&CustomerId: Based on the CustomerId attribute
&xml: Character(200)

and design the Web Panel screen like this:


The following code is associated with the Web Panel button:

Event 'ToXml'

In run-time, suppose you enter the value: 1 in the &CustomerId variable and then press the button. The customer data is loaded in the &Customer variable and converted to XML format, as the following image shows:

<Customer xmlns=“knowledgeBase”>
    <CustomerName>Jack Smith </CustomerName>
    <CustomerAddress>2300 East Avenue </CustomerAddress>
    <CustomerPhone>12103110700 </CustomerPhone>
    <CustomerName_Z> Jack Smith </CustomerName_Z>
    <CustomerAddress_Z>2300 East Avenue </CustomerAddress_Z>
    <CustomerPhone_Z>12103110700 </CustomerPhone_Z>

See Also

Business Components Methods


Last update: November 2023 | © GeneXus. All rights reserved. GeneXus Powered by Globant