Jump to content
Sign in to follow this  

How to create a special format attribute in XML file

Recommended Posts


I am still new to AutoIT. I have included _XMLDomWrapper.au3 in my script and tried using _XMLCreateAttrib and _XMLCreateChildWAttr methods.

I need to add the below attribute into the XML file after the "ip" attribute.


<displayFieldUUID name="task">A23ET45</displayFieldUUID>

XML File:

<?xml version="1.0" encoding="UTF-8" ?>

- <configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="mapping_schema.xsd">


<publisher name="ABCD" />


- <application CRUDOptions="IGNORE" name="Application">


- <searchField>

<displayFieldUUID name="ip">B405EFDB</displayFieldUUID>

<displayFieldUUID name="criticality">E94E9D77</displayFieldUUID>




I tried the following method but it gives error.

$strAttribName = "task"

$strAttribValue = "A23ET45"

_XMLCreateAttrib("//configuration/application/searchField/displayFieldUUID", $strAttribName, $strAttribValue)


Share this post

Link to post
Share on other sites

Here is an example:

$string = '<XML><Group name="Office1"><host><name>O1Pc1</name><ip></ip></host><host><name>O1Pc2</name><ip></ip></host></Group><Group name="Office2"><host><name>O2Pc1</name><ip></ip></host><host><name>O2Pc2</name><ip></ip></host></Group></XML>'
;$XML = @DesktopDir & "xml1.xml"
;$oXML.load($XML) ; load document
$oXML.loadxml($string) ; load document
ConsoleWrite ( $oXML.xml & @CRLF)
$iCounter = 1
$result = $oXML.selectNodes( '//Group' )

For $oNode In $result
$oNode.setattribute ("something", 'test' & $iCounter)
$iCounter += 1
ConsoleWrite ( $oXML.xml & @CRLF)

That creates an attribute, which you may then associate to a node object (cannot use xpath with .setattribute)

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.