Jump to content

Recommended Posts

Posted

hi, i have an xml like

<configuration>
    <appSettings>
        <add key="root_path" value="D:\MvpT2Data"/>
    </appSettings>
</configuration>

using _xml UDF how do i add a key AND and value in the same path?

#include "_XMLDomWrapper.au3"
_XMLFileOpen("config.xml")
_XMLCreateChildWAttr("//appSettings","add", "key", "root_pathyy")
Posted (edited)

Does it return the node object? The you could do this:

$Node = _XMLCreateChildWAttr("//appSettings","add", "key", "root_pathyy")

_XMLCreateAttrib($Node,"value","X:\My\Path")

/Edit: No, it doesn't return an object. Instead, use an Array for attribName and attribValue:

Dim $Attribs[2] = ["key","value"]

Dim $values[2] = ["root_pathyy","X:\Path\yy"]

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Posted

I concur with ProgAndy, otherwise you can just create the node, then use _XMLSetAttrib to add the attributes separately.

Posted (edited)

cool, this works

Dim $Attribs[2] = ["key","value"]
Dim $values[2] = ["root_path","X:\Path\yy"] 
_XMLCreateChildWAttr("//appSettings","add", $Attribs, $values)

now, whats the best method to overwrite the older child node?

assume the first attribute (key) stays unchanged but the second (root_path) should be changed.

edit:

weaponx, didnt see your reply, i'll check that setAttrib.

re-edit:

no, i dont get it.

Edited by yair
Posted

What don't you get? The syntax is explained in the UDF. You just have to provide the path to the node you want to change.

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
×
×
  • Create New...