Arfur9 Posted April 15, 2012 Share Posted April 15, 2012 Hi I'm new to AutoIt and I was hoping I could get a little bit of help I'm building a form application which creates batch files for a renderer, so far things are going well but I'm stuck on one thing.I need to look for cameras in a XML file and the user be able to select a camera from a listin the XML the line looks like:<Object Identifier="./Cameras/Scene 1" Label="Pinhole Camera" Name="Scene 1" Type="Camera">"Scene 1" being the cameraThere can be any amount of cameras in a scene,If you need the actual xmlhttp://dl.dropbox.com/u/26539256/batchtool/Untitled.xmlI'd be grateful for any helpif your interested the batch file creator is going to be a AutoIt version of this, I've got all the scene input, save, run done My 3D Work Link to comment Share on other sites More sharing options...
Zedna Posted April 15, 2012 Share Posted April 15, 2012 (edited) #include <String.au3> $xml = FileRead('untitled.xml') $objects = StringRegExp($xml, '<Object(.*?)Type="Camera">', 3) ConsoleWrite('Number of cameras in XML: ' & UBound($objects) & @CRLF) For $i = 0 To UBound($objects) - 1 $object = $objects[$i] ;~ ConsoleWrite('object: ' & $object & @CRLF) $name = GetValue($object, 'Name') ConsoleWrite('camera name: ' & $name & @CRLF) Next Func GetValue($xml_data, $name_col) Return StringBetween($xml_data, $name_col & '="', '"') EndFunc Func StringBetween($sString, $sStart, $sEnd) $sReturn = _StringBetween($sString, $sStart, $sEnd) ;, -1, 1) If @error Then Return '' Return StringStripWS($sReturn[0],3) EndFunc EDIT: output Number of cameras in XML: 2 camera name: ## Current View ## camera name: Scene 1 Edited April 15, 2012 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
ProgAndy Posted April 15, 2012 Share Posted April 15, 2012 Hello,I suppose you should be able to get your data with a regular expression:$text = '<Object Identifier="./Cameras/Scene 1" Label="Pinhole Camera" Name="Scene 1" Type="Camera">' $aCameraList = StringRegExp($text, '(?i)<Objecth+Identifier="([^"]+)"h+Label="([^"]+)"h+Name="([^"]+)"h+Type="Camera"h*>', 4) For $i = 0 To UBound($aCameraList)-1 $aCamera = $aCameraList[$i] MsgBox(0, "", "ID: " & $aCamera[1] & @CRLF & "Label: " & $aCamera[2] & @CRLF & "Name: " & $aCamera[3]) Next *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 Link to comment Share on other sites More sharing options...
Arfur9 Posted April 15, 2012 Author Share Posted April 15, 2012 Thank you for the quick replies! Both examples are awesome My 3D Work Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now