# XML Attribute

**URL:** <https://forum.servoy.com/t/xml-attribute/17659>\
**Category:** Classic Servoy\
**Created:** [November 27, 2013, 9:08pm UTC](https://forum.servoy.com/t/xml-attribute/17659 "2013-11-27T21:08:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevin1379077093](https://avatars.discourse-cdn.com/v4/letter/k/4af34b/32.png) [@kevin1379077093](https://forum.servoy.com/u/kevin1379077093)\
**Post date:** [November 27, 2013, 9:08pm UTC](https://forum.servoy.com/t/xml-attribute/17659/1 "2013-11-27T21:08:13Z")

</div>

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](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

```auto
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:

```auto
<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)

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

```

---

<div class="post-metadata">

**Author:** ![mboegem](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/mboegem/32/4399_2.png) [@mboegem](https://forum.servoy.com/u/mboegem)\
**Post date:** [November 27, 2013, 10:32pm UTC](https://forum.servoy.com/t/xml-attribute/17659/2 "2013-11-27T22:32:48Z")

</div>

Hi,  
This does the job:

```auto
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](https://developer.mozilla.org/en-US/docs/E4X)

---

<div class="post-metadata">

**Author:** ![kevin1379077093](https://avatars.discourse-cdn.com/v4/letter/k/4af34b/32.png) [@kevin1379077093](https://forum.servoy.com/u/kevin1379077093)\
**Post date:** [November 28, 2013, 2:15pm UTC](https://forum.servoy.com/t/xml-attribute/17659/3 "2013-11-28T14:15:19Z")

</div>

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