Jump to content

XML parse and search for duplicates


Recommended Posts

Can someone help me figure out how to import XML and search and output duplicates?

 

I have attached my xml it looks like this. In each section..  

 

<EPOPolicySettings name="McAfee Default (copy)::Settings (5251B0C9-F3DC-4C23-A949-BA34ECDD42D1)" featureid="SCOR_AWL" categoryid="AWL Rules (Windows)" typeid="AWL Rules (Windows)" param_int="0" param_str="">
<Section name="General_Rule_1">
<Setting name="binary" value="ACIntUsr.exe"/>
<Setting name="inherit" value="true"/>
<Setting name="log" value="true"/>
<Setting name="tag" value="Altiris1"/>
<Setting name="type" value="updater-binary"/>
</Section>
<Section name="General_Rule_2">
<Setting name="binary" value="aclient.exe"/>
<Setting name="inherit" value="true"/>
<Setting name="log" value="true"/>
<Setting name="tag" value="Altiris2"/>
<Setting name="type" value="updater-binary"/>
</Section>
<Section name="General_Rule_3">
<Setting name="binary" value="AeXNSAgent.exe"/>
<Setting name="inherit" value="true"/>
<Setting name="log" value="true"/>
<Setting name="tag" value="Altiris3"/>
<Setting name="type" value="updater-binary"/>
</Section>
<Section name="scor_info">
<Setting name="group_name" value="Altiris"/>
<Setting name="group_type" value="application_control"/>
<Setting name="platforms" value="WIN"/>
<Setting name="readOnly" value="true"/>
</Section>
</EPOPolicySettings>

i have started writting like this. but i am very new to this.

#include <_XMLDOMWrapper.au3>

$xml = _XMLFileOpen (@ScriptDir & "\McAfee_Default_(copy).xml")
If @error Then
    ConsoleWrite(_XMLError()&@lf)
    Exit
EndIf

Walk()



Func Walk($path = "*/EPOPolicySettings")
    $a = _XMLGetChildNodes($path)
    If IsArray($a) Then
        For $x = 1 To $a[0]
            If $x > 1 And $a[$x] <> $a[$x - 1] Then
                Dim $num = 0
                $num += 1
            Else
                $num = $x
            EndIf
            ConsoleWrite($path & "/" & $a[$x] & "[" & $num & "]" & @LF)
            Dim $at[1], $av[1]
            $b = _XMLGetAllAttrib($path & "/" & $a[$x] & "[" & $num & "]", $at, $av)
            If Not @error Then
                If IsArray($b) Then
                    For $y = 0 To UBound($at) - 1
                        ConsoleWrite(StringFormat("\t:%s=%s\n", $at[$y], $av[$y]))
                    Next
                EndIf
            EndIf
            Walk($path & "/" & $a[$x] & "[" & $num & "]")
        Next
    EndIf
EndFunc

What i am trying to accomplish is being able to put in any XML file that is similar and search and locate duplicates and output the complete sections where found. Example duplicate hashes.

Can anyone help me out so i can learn?

McAfee_Default_(copy).xml

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...