Jump to content

XML DOM Wrapper - get path of content


Recommended Posts

Hi AutoIT Forum.

I have some problems with the XML DOM Wrapper.

This is my XML for example:

<i>
    <name>INAME1
     <iserver>iserver</iserver>
     <username>username</username>
     <password>password</password>
     <sserver>sserver</sserver>
    </name>
    <name>INAME2
     <iserver>iserver</iserver>
     <username>username</username>
     <password>password</password>
     <sserver>sserver</sserver>
    </name>
    <name>INAME3
     <iserver>iserver</iserver>
     <username>username</username>
     <password>password</password>
     <sserver>sserver</sserver>
    </name>
   </i>

I want to get the path of <name>INAME2. How can i do that?

I want to write and read at this path....

Link to comment
Share on other sites

Why use XML DOM Wrapper? I think this could be done with _StringBetween function (isn't it possible?)

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

Why use XML DOM Wrapper? I think this could be done with _StringBetween function (isn't it possible?)

I don't only want to read from the xml file, also i want to write in it.

I think i have solved the problem nearly with /name[1]...

So i can geht the Index out of an array.

Link to comment
Share on other sites

That isn't well formed XML. If this is your own, i would suggest putting the text into an attribute within the parent tag...then you can use actual XML to specify the parent with a specific attribute value.

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.
Link to comment
Share on other sites

My solution:

; ---------------
$oprofilelesenname = oprofilelesen()
   $file = _XMLFileOpen($sPath)
   $oplna = _ArraySearch($oprofilelesenname, $the_Profile)
   If $oplna = -1 Then
  _XMLCreateChildNode("/o_profiles", "name", $the_Profile)
   EndIf
   _XMLSaveDoc($sPath)
   $oprofilelesenname = oprofilelesen()
   $file = _XMLFileOpen($sPath)
   $oplnaIndex = _ArraySearch($oprofilelesenname, $the_Profile)
   $oprofiles_name = "/o_profiles/name[" & $oplnaIndex & "]"
;------------------

Func oprofilelesen()
   $sPath = @MyDocumentsDir & "OPlug-In TestEingabemaske Profileprofiles.xml"
   $file = _XMLFileOpen($sPath)
   $oprofilelesenname = _XMLGetValue("/o_profiles/name")
 
   _XMLSaveDoc($sPath)
   Return ($oprofilelesenname)
EndFunc

It works very well ;)

Link to comment
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
 Share

×
×
  • Create New...