faustf Posted September 29, 2016 Share Posted September 29, 2016 (edited) hi guys i have a txt expandcollapse popup'<Variation>' & _ '<SKU>!22</SKU>' & _ '<StartPrice>12.00</StartPrice>' & _ '<Quantità>2.00</Quantità>' & _ '<VariationSpecifics>' & _ '<NameValueList>' & _ '<Nome>Taglia</ Nome>' & _ '<Valore>32</ Valore>' & _ '<SKU>!22!23</SKU>' & _ '<VariationSpecifics>' & _ '<NameValueList>' & _ '<Nome>Taglia coppa</ Nome>' & _ '<Valore>A</ Valore>' & _ '</NameValueList>' & _ '</VariationSpecifics> ' & _ '</Variation>' & _ '<Variation>' & _ '<SKU>!23</SKU>' & _ '<StartPrice>11.00</StartPrice>' & _ '<Quantità>1.00</Quantità>' & _ '<VariationSpecifics>' & _ '<NameValueList>' & _ '<Nome>Taglia</ Nome>' & _ '<Valore>34</ Valore>' & _ '<SKU>!22!23</SKU>' & _ '<VariationSpecifics>' & _ '<NameValueList>' & _ '<Nome>Taglia coppa</ Nome>' & _ '<Valore>A</ Valore>' & _ '<SKU>!23</SKU>' & _ '<VariationSpecifics>' & _ '<NameValueList>' & _ '<Nome>Taglia coppa</ Nome>' & _ '<Valore>AA</ Valore>' & _ '</NameValueList>' & _ '</VariationSpecifics> ' & _ '</Variation>' & _ i want transform in this mode '<Variation>' & _ '<SKU>!22</SKU>' & _ '<StartPrice>12.00</StartPrice>' & _ '<Quantità>2.00</Quantità>' & _ '<VariationSpecifics>' & _ '<NameValueList>' & _ '<Nome>Taglia</ Nome>' & _ '<Valore>32</ Valore>' & _ '<Nome>Taglia coppa</ Nome>' & _ '<Valore>A</ Valore>' & _ '<SKU>!23</SKU>' & _ '<StartPrice>11.00</StartPrice>' & _ '<Quantità>1.00</Quantità>' & _ '<VariationSpecifics>' & _ '<NameValueList>' & _ '<Nome>Taglia</ Nome>' & _ '<Valore>34</ Valore>' & _ '<Nome>Taglia coppa</ Nome>' & _ '<Valore>A</ Valore>' & _ '<Nome>Taglia coppa</ Nome>' & _ '<Valore>AA</ Valore>' & _ consider the !22 and !23 can change is variable in text , but is always !number how is possible to do ??? with regexp ?? ? ? thankz Edited September 29, 2016 by faustf Link to comment Share on other sites More sharing options...
genius257 Posted September 30, 2016 Share Posted September 30, 2016 (edited) you could use regexp, or Microsoft.XMLDOM the regexp could look something like: ">(![0-9]+)<" but better, would be: $oXML = ObjCreate("Microsoft.XMLDOM") $oXML.setProperty("SelectionLanguage", "XPath") $sXML = "<Variation><SKU>!22</SKU><Quantità>2.00</Quantità></Variation>" $oXML.LoadXML($sXML) $oNodes = $oXML.selectNodes("//*[contains(./text()[last()],'!') and boolean(number(substring(substring-after(./text()[last()],'!'), 1, 2)))]");select elements, containing [!][0-9]{1,2} MsgBox(0, "", $oNodes.Length);show number of matches Exit You then simply extract the text from node, run a regexp "![0-9]{1,2}" in 1 of 2 ways: 1: use the autoit StringRegExp to get the exact string and replace the part of the string with StringInStr, StringMid and StringLen 2: use "VBScript.RegExp" to get match position with the results and again use StringMid and StringLen to replace the "variables" then set the text of node to the string you just processed and save the xml before exit Also your xml is broken. you have a "VariationSpecifics" element that is not closed. Edited September 30, 2016 by genius257 My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser 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