XML Attribute

Hi there .

is it possible to add an attribute to an XML node when using the servoy built in XML methods? ( https://wiki.servoy.com/display/Serv52/XML). I cant seem to find any reference to adding an attribute… only references to listing an attribute.

So for example

The following code

var _xml = <xml/>;

_xml.myTestXML = <myTestXML/>
var _HeaderInfo = <HeaderInfo/>

var _Sender = <Sender/>;
_Sender.PrimaryID = "test";

_HeaderInfo.Sender = _Party;

_xml.myTestXML.appendChild(_HeaderInfo);
application.output(_xml);

produces the following output:

<xml>
  <myTestXML>
    <HeaderInfo>
      <Sender>
        <PrimaryID>test</PrimaryID>
      </Sender>
    </HeaderInfo>
  </myTestXML>
</xml>

But I want it to produce output like this. (the difference is the additional [testattribute = "hello ] value on the [primary ID] node)

<xml>
  <myTestXML>
    <HeaderInfo>
      <Sender>
        <PrimaryID testattribute = "hello" >test</PrimaryID>
      </Sender>
    </HeaderInfo>
  </myTestXML>
</xml>

Hi,
This does the job:

var _xml = <xml/>;

	_xml.myTestXML = <myTestXML/>
	var _HeaderInfo = <HeaderInfo/>

	var _Sender = <Sender/>;
	_Sender.PrimaryID = "test";
	_Sender.PrimaryID.@testattribute = "hello";
	

	_HeaderInfo.Sender = _Sender;

	_xml.myTestXML.appendChild(_HeaderInfo);
	application.output(_xml);

Here’s to find more information of the E4X implementation: https://developer.mozilla.org/en-US/docs/E4X

Hey Marc… thanks for that. I appreciate the direction and the link to the docs.
Kevin