Floppy Posted November 14, 2012 Posted November 14, 2012 Hi, I'm trying to get 'abc' from the following code (extracted from a web page) class="item"> <div style="display: none;" class="cms">abc</div> AutoIT script $body = _IEBodyReadHTML($ie) $result = _StringBetween($body, 'class="item"> <div style="display: none;" class="cms">', '</div>') It doesn't find anything because I don't know how to specify that the text is on two lines. Can someone help me, please?
JohnOne Posted November 14, 2012 Posted November 14, 2012 post how you get result AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
JohnOne Posted November 14, 2012 Posted November 14, 2012 Never mind, just try this. $body = _IEBodyReadHTML($ie) $body= StringStripWS($String, 8) $result = _StringBetween($String, 'class="item"><divstyle="display:none;"class="cms">', '</div>') first you strip any white space, which includes line feeds and such. Floppy 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
dany Posted November 14, 2012 Posted November 14, 2012 Or more conservative in stripping only linefeeds between > and < tags. $body = _IEBodyReadHTML($ie) $body= StringRegExpReplace($body, '>[rn]+<', '><') $result = _StringBetween($String, '<class="item"><div style="display: none;" class="cms">', '</div>') [center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF
FireFox Posted November 14, 2012 Posted November 14, 2012 Why not this? : $result = _StringBetween($body, 'class="item">' & @CrLf & '<div style="display: none;" class="cms">', '</div>')
jdelaney Posted November 14, 2012 Posted November 14, 2012 (edited) I'm always posting these, but I'd rather (and suggest), the use of any DOM object to parse out data from [xml|XML-like] structures. $oXML=ObjCreate("Microsoft.XMLDOM") $sXML= '<root><li class="item"><div style="display: none;" class="cms">abc</div></li></root>' $oXML.loadxml($sXML) ;ConsoleWrite ( $oXML.xml & @CRLF ) $oElement = $oXML.SelectSingleNode ( "//li[@class='item']/div[@class='cms']" ) ConsoleWrite ( $oElement.text & @CRLF ) Edited November 14, 2012 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.
EmptySpace Posted November 14, 2012 Posted November 14, 2012 _Stringbetween returns array. Maybe you dont convert it into string. Msgbox wont show anything. Search in help file for arraytostring or something like that (forgot..)
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