Jump to content

Trying to understand Objects


Recommended Posts

Hi all,

I've recently be kinda forced into trying to learn OOP within AutoIt. I'm trying to convert XML into objects I guess instead of trying to parse it into arrays within arrays. An example is below:

<User>
    <roles>
        <role>Agent</role>
        <role>Supervisor</role>
    </roles>
</user>

 

  • How can I convert this?
  • Would <roles> be $User.Roles?
  • If so would the children be $User.Roles.Role.Agent and $User.Roles.Role.Supervisor? 
  • If not, how do I reference each Object?
     

Any assistance would be appreciated. I tried to understand XML.au3 but I'm so confused trying to wrap my head around this.

Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Link to comment
Share on other sites

Forum search .selectnodes.  return that to a variable like $oRoles.  xpath is //role

Loop through like:

For $oRole in $oRoles

     consolewrite  ($oRole.text & @crlf)

Next

 

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

_XML_SelectNodes expects XML input for the first parameter and the "path" as the second? Does it return an array or strings? I'm still so confused at exactly the $oNodes_coll return is...

Edit: Just saw your edit. I'll try that.

Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Link to comment
Share on other sites

I seem to be getting a DOMVersion (4) error. However @extended is "0". I'm confused if I'm doing something wrong?

Edit: It appears I'm getting IsNotObject. I guess I need to convert my XML text to an Object for the First Parameter of _XML_SelectNodes?

Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

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...