Jump to content
Sign in to follow this  
MvL

Split the DOM load (highlighted and as attachment)

Recommended Posts

MvL

I worked out a script to split an XML string by tag. The result is put in an array.

Other info like the name of the parent node that goes with a result is stored in separate arrays.

The XML string represents a DOM load.

The main script is:

Share this post


Link to post
Share on other sites
MvL

; Filename: XML split the DOM load.au3
; Author: Martin van Leeuwen
; Date: 15-okt-2012

#include '..XMLincludePartsXML_split_the_DOM_load.au3'
#include <Array.au3>
#include <Timers.au3> ; For measuring script performance

Global $showResults, $FileName, $Id, $sContent, $sSearchTag, $sFilterNodeName, $booleanFilterIsEnclosed
Global $arrKeepFilteredValues[1] ; Reserved variable
Global $arrFilteredNodesValues[1], $arrIndNr[1], $arrIndStr[1], $arrParentNodeAndValue[1], $arrResult[1], _
$arrNextLevels[1], $arrFirstChild[1]
Global $isLeveled, $iSelected, $eval, $occurence
Global $StartTime
Global $askFile


$askFile = False
If $AskFile Then
$FileName = @ScriptDir & '' & 'cup and saucer.xml'
; $FileName = FileOpenDialog('Open xml load file', @MyDocumentsDir & '', 'All (*.*)', 1 + 4 , $FileName)

$Id = FileOpen($FileName)
If $Id = -1 Then
iii('Bestand niet gevonden.')
Exit
EndIf
$sContent = FileRead($Id)
FileClose($Id)
$sSearchTag = '<box>'
$sFilterNodeName = '<room>' ; case sensitive
$booleanFilterIsEnclosed = True
Else
$sContent = '<house>' & _
'<room>' & _
'left' & _
'<trunk>big' & _
'<box>bread</box>' & _
'<box>butter</box>' & _
'<box>' & _
Chr(12) & Chr(10) &'cup <box>spoon</box> mystery </box>' & _
'</trunk>' & _
'</room>' & _
'<room> right' & _
'<trunk>small' & _
'<box>saucer<color>blue </color></box>' & _
'</trunk>' & _
'</room>' & _
'</house>'

$sSearchTag = '<box>'
$sFilterNodeName = '<room>' ; case sensitive
$booleanFilterIsEnclosed = True
EndIf

; Further analysed is needed in a While loop over the index of the array(s),
; to find our expected result: 'saucer'
$StartTime = _Timer_Init()
$iSelected = 0
$showResults = True
$eval = "$arrFilteredNodesValues[$iSelected] = '/left/' And $arrParentNodeAndValue[$iSelected] = '<trunk>/big/' And $arrNextLevels[$iSelected] > 0 "
$occurence = 0
$isLeveled = _
XML_split_the_DOM_load($sContent, $sSearchTag, $sFilterNodeName, $booleanFilterIsEnclosed, $arrKeepFilteredValues, _
$arrFilteredNodesValues, $arrIndNr, $arrIndStr, $arrParentNodeAndValue, $arrResult, $arrNextLevels, $arrFirstChild, $showResults)
; Duration of the function call was: 2,5 msec

If @error <> 0 Then
MsgBox(4096, '', '$sSearchTag misses < or > ')
ElseIf ($arrResult[0] <= 0) Then
MsgBox(4096, '', 'Geen ' & $sSearchTag & ' gevonden.')
Else ; Begin $sSearchTag
$StartTime = _Timer_Init()
While True
     $iSelected = $iSelected + 1
     If $iSelected > $arrResult[0] Then
         $iSelected = 0
         MsgBox(4096, '', 'Niet gevonden: ' & $eval )
         ExitLoop
     EndIf
     If Execute($eval) Then
         $occurence = $occurence + 1
         If $occurence = 2 Then ExitLoop
     EndIf
WEnd
EndIf ; End $sSearchTag
If $iSelected > 0 Then
MsgBox(4096, _Timer_Diff($StartTime) & ' + msec', 'Result for: ' & $eval & @CRLF & $arrResult[$iSelected]) ; saucer
EndIf

Edited by MvL

Share this post


Link to post
Share on other sites
MvL

; #FUNCTION# ======================================================================================================
; Name...........: XML_split_the_DOM_load
; Description ...: Parser for a XML file by splitting it's DOM load by a specific tag.
;                . Parsing nesting tag's is supported.
;                . Parse and filter is supported.
;                . The results are returned in six ByRef arrays parameters,
;                    to be further analysed in a While loop over the index of the array(s).
;                . The DOM load is assumed to be valid:
;                    Besides a rudimentary check on the presence of at least one '<' and one '>'
;                    there is no additional check on consistent use of '<' '>' or '</' '>' or '<' '/>'
;                    In other words: The split always succeeds.
; Syntax.........: ..
; Parameters ....:
; $_sContent     : The XML content to split.
; $_sSearchTag  : The search tag, with opening < and closing >
; $_sFilterNodeName : The node names of which the values ar ticked in $_aFilteredNodesValues
; $_bFilterIsEnclosed : False: the values in aray $_aFilteredNodesValues are allowed to run wide.
; $_aKeepFilteredValues: : Array reserved for in-line filtering.
;
;    Six resulting arrays ByRef, to be declared as input with one element, syntax: $_aName[1].
;       The number of elements is dynamically expanended.
;       The five arrays keep up with the same number of elements.
;       This number is stored in array element 0.
;       Trim Whitespaces (leading and trailing) includes Chr(9) thru Chr(13) which are
;       HorizontalTab, LineFeed, VerticalTab, FormFeed, and CarriageReturn.
;       Whitespace also includes the null string ( Chr(0) ) and the standard space ( Chr(32) ).
; ByRef $_aFilteredNodesValues: The array with the ticked nodes /values/, without white spaces.
; ByRef $_aIndNr    : Array: The number of open parent-nodes (for each result).
; ByRef $_aIndStr   : Array: String of dots, visualizing the number of open parent-nodes (for each result).
; ByRef $_aParentNodeAndValue : Array: The name of the <parent-node> and /value/, without white spaces.
; ByRef $_aResult   : Array: Each split result.
; ByRef $_aNextLevels : Array: The depth of tags of the samen search-tags (for each result).
; ByRef $_aFirstChild : Array: The first child-node and value, after the search-tag (for each result).
;
; $_showResults : Indication to show all results and arrays.
; $_firstTime = True : Boolean, should not be added to the function call, is for handling extra levels.
; $_iPointer = 1     : Integer, should not be added to the function call, is for handling extra levels.
; Global $_C_ActionflowMode : Optional. 0 = interactive, 9 = unattended.
;
; Return values .: $_MoreLevels: True when array elements contain next levels of search tags.
;    Six arrays : The five arrays above are both for input ($_firstTime = True) as output.
;    @error  : If the $_sSearchTag has no delimeters < or > then the @error is set to 1.
;
; Author ........: Martin van Leeuwen
; Modified.......: 19 okt 2012

Edited by MvL

Share this post


Link to post
Share on other sites
Melba23

MvL,

My patience with you is wearing thin. Why always these separate posts and now another thread? You do not win prizes for post count here, you know. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
MvL

; The short version, using include files, is:
; (You can copy this function to a new name, and alter the Filter logic)

Func XML_split_the_DOM_load($_sContent, $_sSearchTag, $_sFilterNodeName, $_bFilterIsEnclosed, $_aKeepFilteredValues, _
ByRef $_aFilteredNodesValues, ByRef $_aIndNr, ByRef $_aIndStr, ByRef $_aParentNodeAndValue, ByRef $_aResult, _
ByRef $_aNextLevels, ByRef $_aFirstChild, _
$_showResults, $_firstTime = True, $_iPointer = 1)

Local $nodeName, $nodeValue, $nodeValueTicked

#include '..XMLincludePartsXMLinludePart1.au3'

; Filter logic:
     $nodeValueTicked = ($_sFilterNodeName <> '') And ($nodeName == $_sFilterNodeName) ; Case sensitive
     If $nodeValueTicked Then
     _ArrayAdd($_aKeepFilteredValues, StringStripWS($nodeValue, 3)) ; 3 = stripped from leading and trailing CR, spaces.
     $_aKeepFilteredValues[0] = $_aKeepFilteredValues[0] + 1
     EndIf

#include '..XMLincludePartsXMLinludePart2.au3'

     XML_split_the_DOM_load($_sContent, $_sSearchTag, $_sFilterNodeName, $_bFilterIsEnclosed, $_aKeepFilteredValues, _
     $_aFilteredNodesValues, $_aIndNr, $_aIndStr, $_aParentNodeAndValue, $_aResult, $_aNextLevels, $_aFirstChild, _
     $_showResults, False, $_iPointer)

#include '..XMLincludePartsXMLinludePart3.au3'

Return $_MoreLevels
EndFunc ;==>XML_split_the_DOM_load




; The long version is:



Func XML_split_the_DOM_load($_sContent, $_sSearchTag, $_sFilterNodeName, $_bFilterIsEnclosed, $_aKeepFilteredValues, _
ByRef $_aFilteredNodesValues, ByRef $_aIndNr, ByRef $_aIndStr, ByRef $_aParentNodeAndValue, ByRef $_aResult, _
ByRef $_aNextLevels, ByRef $_aFirstChild, _
$_showResults, $_firstTime = True, $_iPointer = 1)

Local $nodeName, $nodeValue, $nodeValueTicked

; Begin #include '..XMLincludePartsXMLinludePart1.au3'
Local $_nodeNameLength, $_conditionLevels = -1
Local $_aOccurences, $_nrOccurences, $_arrShowMax = 40, $_arrShow[$_arrShowMax][8], $_nrToShow, $_startTime, $_diffTime
Local $_waarde, $_nrSubLoops, $_nrOfNextLevels, $_MoreLevels = False
Local $_aSplit, $_iLoop, $_arrWaarde[3], $_iWaarde
Local $_sMatchSearchTag, $_sMatchSearchTagLen, $_searchNoDelim, $_blok, $_stop, $_stopLen, $_sMatchSearchTagFound
Local $_ParentNodeName, $_ParentNodeNameLen, $_ParentNodeValue, $_sFirstChild, $_FirstChildLen
Local $_sMatchFilterNode, $_sMatchFilterNodeLen, $_endFilter, $_endFilterLen
Local $_iPointerDiff, $_aPointerDiff[2], $_iDots
Local $_str, $_arrTag
Local $_arr1[1] ; Initial arrays
Const $_caseSense = 2 ; preferably 2 not case sensitive, using a basic/faster comparison ;0 = not case sensitive, using the user's locale (default) ;1 = case sensitive
If (Stringleft($_sSearchTag, 1) <> '<') Or (StringRight($_sSearchTag, 1) <> '>') Then
SetError(1)
Return False
EndIf

If $_showResults Then $_startTime = _Timer_Init()
$_sMatchSearchTag = StringMid($_sSearchTag, 2) ; drop the '<'
$_sMatchSearchTagLen = StringLen($_sMatchSearchTag)
$_searchNoDelim = StringTrimRight($_sSearchTag, 1) ; drop the '>'
$_searchNoDelim = StringMid($_searchNoDelim, 2) ; drop the '<'
$_blok = $_searchNoDelim & '/>'
$_stop = '/'& $_searchNoDelim & '>'
$_stopLen = $_sMatchSearchTagLen + 1

$_aSplit = StringSplit($_sContent, '<', 1)
; If $_firstTime Then _ArrayDisplay($_aSplit, '$_aSplit[0] ' & $_aSplit[0] & ', $_nrOccurences: '& $_nrOccurences)
$_arr1[0] = 0
If $_firstTime Then
$_aSplit[1] = '>'
; Remember the number of times that the tag is found for the First time in de $_sContent, to skip out of the while loop when the last occurrence is found.
$_nrOccurences = $_aResult[0] ; Offset value
$_aOccurences = StringSplit($_sContent, $_sSearchTag, 1) ; 1 = (for the first time) split on the whole $_sSearchTag string.
$_nrOccurences = $_nrOccurences + ( $_aOccurences[0] - 1 )
$_aOccurences = StringSplit($_sContent, '<' & $_blok , 1)
$_nrOccurences = $_nrOccurences + ( $_aOccurences[0] - 1 )
; Initiate
$_aIndNr = $_arr1
$_aIndStr = $_arr1
$_aParentNodeAndValue = $_arr1
$_aResult = $_arr1
$_aNextLevels = $_arr1
$_aFirstChild = $_arr1
Else
$_aSplit[1] = $_sMatchSearchTag & $_aSplit[1]
EndIf
$_aPointerDiff[0] = 1
$_aPointerDiff[1] = 1 ; This element now points to $_aSplit[1], containing $_sSearchTag or '<>'
$_iPointerDiff = 1 ; There is one pointer in the array $_aPointerDiff[]
If $_firstTime Then
$_aKeepFilteredValues = $_arr1
_ArrayAdd($_aKeepFilteredValues, '')
$_aKeepFilteredValues[0] = 1
EndIf
If ($_sFilterNodeName <> '') Then
$_sMatchFilterNode = StringMid($_sFilterNodeName, 2) ; drop the '<'
$_sMatchFilterNodeLen = StringLen($_sMatchFilterNode)
$_endFilter = '/'& $_sMatchFilterNode
$_endFilterLen = $_sMatchFilterNodeLen + 1
EndIf

$_iLoop = 2
While $_iLoop <= $_aSplit[0] ; Loop over all pieces

If StringLeft($_aSplit[$_iLoop], 1) == '/' Then ; '</' This one first, use the fastest comparison that is case sensitive ==
; EndTag '</'
$_iPointerDiff = $_iPointerDiff - 1
$_iPointer = $_iPointer - 1

; ###################### FILTER START for EndTag '</' ############################
If ($_sFilterNodeName <> '') And $_bFilterIsEnclosed Then
    If StringLeft($_aSplit[$_iLoop], $_endFilterLen) == $_endFilter Then ; case sensitive
     ; shorten the array $_aKeepFilteredValues by 1 element.
     If $_aKeepFilteredValues[0] > 1 Then
     $_arrTag = $_arr1
     $_arrTag[0] = $_aKeepFilteredValues[0] - 1
     For $iTag = 1 To $_arrTag[0]
     _ArrayAdd($_arrTag, $_aKeepFilteredValues[$iTag])
     Next
     $_aKeepFilteredValues = $_arrTag
     EndIf
    EndIf
EndIf
; ###################### FILTER END for EndTag '</' ############################

; EndTag '</'
Else
; Begin Tag '<'
$_iPointerDiff = $_iPointerDiff + 1
$_iPointer = $_iPointer + 1
If $_iPointerDiff > 0 Then
    If $_iPointerDiff <= $_aPointerDiff[0] Then
     $_aPointerDiff[$_iPointerDiff] = $_iLoop
    Else
     _ArrayAdd($_aPointerDiff, $_iLoop)
     $_aPointerDiff[0] = $_aPointerDiff[0] + 1
    EndIf
EndIf
$_sMatchSearchTagFound = StringLeft($_aSplit[$_iLoop], $_sMatchSearchTagLen) == $_sMatchSearchTag
If Not $_sMatchSearchTagFound And Not (StringLeft($_aSplit[$_iLoop], $_sMatchSearchTagLen + 1) == $_blok) Then ; '<'
    If StringInStr($_aSplit[$_iLoop], '/>') Then ; /> immediately ends the tag
     $_iPointerDiff = $_iPointerDiff - 1
     $_iPointer = $_iPointer - 1
    Else ; begin simple '<'
     $_nodeNameLength = StringInStr($_aSplit[$_iLoop], '>')
     $nodeName = '<' & StringLeft($_aSplit[$_iLoop], $_nodeNameLength)
     $nodeValue = StringMid ($_aSplit[$_iLoop], $_nodeNameLength + 1)
     ; simple '<'
     ; End #include '..XMLincludePartsXMLinludePart1.au3'

     ; ######## FILTER LOGIC ########
     $nodeValueTicked = ($_sFilterNodeName <> '') And ($nodeName == $_sFilterNodeName) ; Case sensitive
     If $nodeValueTicked Then
     _ArrayAdd($_aKeepFilteredValues, StringStripWS($nodeValue, 3)) ; 3 = stripped from leading and trailing CR, spaces.
     $_aKeepFilteredValues[0] = $_aKeepFilteredValues[0] + 1
     EndIf
     ; ######## FILTER LOGIC ########

     ; Begin #include '..XMLincludePartsXMLinludePart2.au3'
    EndIf ; end simple '<'
Else ; $_sMatchSearchTagFound Or ( StringLeft($_aSplit[$_iLoop], $_sMatchSearchTagLen + 1) == $_blok)
    $_nrOfNextLevels = 0
    $_waarde = ''
    $_arrWaarde[1] = ''
    If $_sMatchSearchTagFound Then
     $_waarde = StringMid($_aSplit[$_iLoop], $_sMatchSearchTagLen + 1) ; the value is the remainder, up to the next <
     $_arrWaarde[1] = $_waarde ; don't strip the value StringStripWS($_waarde, 3) ; stripped from CR and 3 = stripped from leading and trailing WhiteSpaces
     $_iLoop = $_iLoop + 1
     $_nrSubLoops = 0
     $_nrOfNextLevels = 0
     $_sFirstChild = ''
     While $_iLoop <= $_aSplit[0] ; Loop over all pieces
     If StringLeft($_aSplit[$_iLoop], $_sMatchSearchTagLen + 1) == $_stop Then ; looking for the stop-tag.
     If $_nrSubLoops = 0 Then ExitLoop
     $_nrSubLoops = $_nrSubLoops - 1
     Else
     $_arrTag = StringSplit($_aSplit[$_iLoop], '>', 1)
     ; We are in the loop for $_sMatchSearchTagFound, and on the next tag. The stop-tag is not found yet.
     ; So we have a child node
     If ($_sFirstChild = '') _ ; First child node
         And (StringRight($_arrTag[1], 1) <> '/') Then ; not an end tag
        $_sFirstChild = '<' & $_arrTag[1] & '>'
        If $_arrTag[0] > 1 Then ; There is a remainder behind the '>' of the child node
         $_sFirstChild = $_sFirstChild & '/'& StringStripWS($_arrTag[2], 3) & '/'
        EndIf
     EndIf
     If $_arrTag[1] == $_searchNoDelim Then
        $_nrSubLoops = $_nrSubLoops + 1
        $_MoreLevels = True
        If $_nrSubLoops > $_nrOfNextLevels Then
         $_nrOfNextLevels = $_nrSubLoops
        EndIf
     EndIf
     EndIf
     $_waarde = $_waarde & '<' & $_aSplit[$_iLoop]
     $_iLoop = $_iLoop + 1
     Wend
    EndIf
    $_arrTag = StringSplit($_waarde, '>', 1) ; The value after any last tag, in $_waarde the next level string
    $_arrWaarde[2] = $_arrTag[$_arrTag[0]]; Don't strip the value StringStripWS($_arrTag[$_arrTag[0]], 3) ; stripped from CR and 3 = stripped from leading and trailing WhiteSpaces

    $_iWaarde = 0
    While $_iWaarde < 2
     $_iWaarde = $_iWaarde + 1
     $_iDots = $_iPointer - 2
     ; ---- Add element to $_aFilteredNodesValues[] ----
     If $_aKeepFilteredValues[0] = 1 Then
     _ArrayAdd($_aFilteredNodesValues, '')
     Else
     _ArrayAdd($_aFilteredNodesValues, '/' & _ArrayToString($_aKeepFilteredValues, '/', 2, $_aKeepFilteredValues[0]) & '/')
     EndIf
     $_aFilteredNodesValues[0] = $_aFilteredNodesValues[0] + 1

     ; ---- Add element to $_aIndNr[] ----
     _ArrayAdd($_aIndNr, $_iDots)
     $_aIndNr[0] = $_aIndNr[0] + 1

     ; ---- Add element to aIdentStr[] ----
     $_str = ''
     If $_iDots > 0 then
     For $_j = 1 to $_iDots
     $_str = $_str & '.'
     Next
     _ArrayAdd($_aIndStr, $_str & 'x' )
     Else
     For $_j = 1 to Abs($_iDots )
     $_str = $_str & '-'
     Next
     _ArrayAdd($_aIndStr, 'x' & $_str )
     Endif
     $_aIndStr[0] = $_aIndStr[0] + 1

     ; ---- Add element to Parent nodes[] ----
     If $_iPointerDiff >= 2 then
     $_str = $_aSplit[$_aPointerDiff[$_iPointerDiff - 1]]
     $_ParentNodeNameLen = StringInStr($_str, '>')
     $_ParentNodeName = '<' & StringLeft($_str, $_ParentNodeNameLen)
     $_ParentNodeValue = StringStripWS(StringMid($_str, $_ParentNodeNameLen + 1), 3)
     ; nodes and there values are anchors for filtering. The value's must be stripped from CR and 3 = stripped from leading and trailing WhiteSpaces
     _ArrayAdd($_aParentNodeAndValue, $_ParentNodeName & '/' & $_ParentNodeValue & '/')
     Else
     _ArrayAdd($_aParentNodeAndValue, '<>' )
     Endif
     $_aParentNodeAndValue[0] = $_aParentNodeAndValue[0] + 1

     ; ---- Add element to $_aResult[] ----
     _ArrayAdd($_aResult, '/' & $_arrWaarde[$_iWaarde] & '/')
     $_aResult[0] = $_aResult[0] + 1

     ; ---- Add element to $_aNextLevels[] ----
     _ArrayAdd($_aNextLevels, $_nrOfNextLevels)
     $_aNextLevels[0] = $_aNextLevels[0] + 1

     ; ---- Add element to $_aFirstChild[] ----
     If ($_iWaarde = 1) Then
     _ArrayAdd($_aFirstChild, $_sFirstChild)
     Else
     _ArrayAdd($_aFirstChild, '')
     EndIf
     $_aFirstChild[0] = $_aFirstChild[0] + 1

     If $_nrOfNextLevels = 0 Then ExitLoop
     If ($_iWaarde = 2) Then ExitLoop
     $_sContent = $_waarde ; to make the next call look similar to the first call
     ; End #include '..XMLincludePartsXMLinludePart2.au3'


     XML_split_the_DOM_load($_sContent, $_sSearchTag, $_sFilterNodeName, $_bFilterIsEnclosed, $_aKeepFilteredValues, _
     $_aFilteredNodesValues, $_aIndNr, $_aIndStr, $_aParentNodeAndValue, $_aResult, $_aNextLevels, $_aFirstChild, _
     $_showResults, False, $_iPointer)

     ; Begin #include '..XMLincludePartsXMLinludePart3.au3'
     ; $_iPointer has been called by value (not ByRef) so it's value is local, and has not been changed by XML_split_the_DOM_load()
     If ($_iWaarde = 1) And ($_arrWaarde[2] = '') Then ExitLoop
     $_nrOccurences = $_nrOccurences + 1 ; For ($_arrWaarde[2] <> '')
    WEnd

    $_iPointerDiff = $_iPointerDiff - 1
    $_iPointer = $_iPointer - 1
    If $_firstTime and ($_aResult[0] = $_nrOccurences) Then ExitLoop ; For efficiency.
EndIf ; End of begin Tag '<'
EndIf ; End of end Tag '</'
$_iLoop = $_iLoop + 1
Wend
If $_firstTime And $_showResults And (Eval('C_ActionflowMode') <> 9 ) Then
$_diffTime = _Timer_Diff($_startTime)
$_arrShow[0][0] = $_aResult[0] & ' *'
$_arrShow[0][1] = 'Ticked ' & $_sFilterNodeName & '''s /value(s), stripped/'
$_arrShow[0][2] = 'Indents'
$_arrShow[0][3] = 'Dots'
$_arrShow[0][4] = '<parent> with /value, stripped '
$_arrShow[0][5] = $_sSearchTag & '''s /value, not stripped/'
$_arrShow[0][6] = 'Next levels'
$_arrShow[0][7] = 'First <child> with /value, stripped/'
$_nrToShow = $_aResult[0]
If $_nrToShow > $_arrShowMax - 1 Then
$_nrToShow = $_arrShowMax - 1
MsgBox(4096, '', 'Only ' & $_nrToShow & ' of the ' & $_aResult[0] & ' results are shown.')
EndIf
For $_i = 1 to $_nrToShow
$_arrShow[$_i ][0] = ''
$_arrShow[$_i ][1] = $_aFilteredNodesValues[$_i ]
$_arrShow[$_i ][2] = $_aIndNr[$_i ]
$_arrShow[$_i ][3] = $_aIndStr[$_i ]
$_arrShow[$_i ][4] = $_aParentNodeAndValue[$_i ]
$_arrShow[$_i ][5] = $_aResult[$_i ]
$_arrShow[$_i ][6] = $_aNextLevels[$_i ]
$_arrShow[$_i ][7] = $_aFirstChild[$_i ]
Next
_ArrayDisplay($_arrShow, $_diffTime & ' msec.', $_nrToShow)
Endif
; End #include '..XMLincludePartsXMLinludePart3.au3'


Return $_MoreLevels
EndFunc ;==>XML_split_the_DOM_load

Edited by MvL

Share this post


Link to post
Share on other sites
MvL

Thank you for the assistance.

Share this post


Link to post
Share on other sites
MvL

[autoit]

; The results that will be shown are:

; 6 rows |Ticked <room>'s|Ind.| Dots |<parent> with |<box>'s |Next |First <child> with

; |with /stripped value(s)/ /stripped value/ |/value, not stripped/ |levels |/value, stripped/

; [1] |/left/ |3 |...x |<trunk>/big/ |/bread/ |0 |

; [2] |/left/ |3 |...x |<trunk>/big/ |/butter/ |0 |

; [3] |/left/ |3 |...x |<trunk>/big/ |/~~cup / |1 |<box>/spoon/

; [4] |/left/ |4 |....x|<box>/cup/ |/spoon/ |0 |

; [5] |/left/ |3 |...x |<trunk>/big/ |/ mystery / |1 |

; [6] |/right/ |3 |...x |<trunk>/small/ |/saucer/ |0 |<color>/blue/

; Further analysed that is performed in the While loop of the main scripts, renders:

; / mystery /

;as result of the selection:

$eval = _

"$arrFilteredNodesValues[$iSelected] = '/left/' "& _

" And $arrParentNodeAndValue[$iSelected] = '<trunk>/big/' " & _

" And $arrNextLevels[$iSelected] > 0 "

; Here's an additional function.

Func node($var)

Local $arr

$arr = StringSplit($var, '<>', 0)

if $arr[0] = 1 Then

Return ''

Else

Return '<' & $arr[2] & '>'

EndIf

EndFunc ;==>node

[autoit]

Edited by MvL

Share this post


Link to post
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
Sign in to follow this  

×