Sign in to follow this  
Followers 0
AlbatorV

XLM read value and delete

5 posts in this topic

Hi, i need help to read <pathstring> value, check if path exists, if not delete from <path color= to </path>

Here my xlm file...

<?xml version="1.0" encoding="UTF-8"?>
<foldercolors>
    <path color="{2F499E2B-8B6E-4B80-8E3B-C73E032E801F}">
        <dir>
            <pathstring>C:\EXISTE</pathstring>
        </dir>
    </path>
    <path color="{FEDC8A0B-6F3B-4113-A733-17A008C87ADB}">
        <dir>
            <pathstring>C:\NEXISTEPAS</pathstring>
        </dir>
    </path>
</foldercolors>

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

First many thanks for this example...

Now my problem... my extension's file is "*.oxc". With this extension, nothing work... if i rename to *.xml, it's ok, value can be read.

And i don't understand why existing path are deleted with my script...

#include "_XMLDomWrapper.au3"
#include <Array.au3>

$sFile = "C:\TEMP\foldercolors.oxc"
$ret = _XMLFileOpen ($sFile)        
        
for $i=1 to 100
    $pathstring = _XMLGetValue("/foldercolors/path[" & $i & "]/dir/pathstring")
    If NOT FileExists($pathstring) Then
        _XMLDeleteNode("/foldercolors/path[" & $i & "]")
    EndIf
next
Edited by AlbatorV

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Please i need help again...

i don't understand why all non existing path are not delete. i need to execute my script 3 or 4 times to delete all path...

#include "_XMLDomWrapper.au3"
#include <Array.au3>

$sFile = "C:\TEMP\foldercolors.xml"
$ret = _XMLFileOpen ($sFile)    
        
For $i=1 to _XMLGetNodeCount("/foldercolors/path")
    $pathstring = _XMLGetValue("/foldercolors/path[" & $i & "]/dir/pathstring")
    If IsArray($pathstring) Then
        If NOT FileExists($pathstring[1]) Then
            _XMLDeleteNode("/foldercolors/path[" & $i & "]")
        EndIf
    EndIf
Next

foldercolors.xml

Edited by AlbatorV

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

this what you wanted or no?

#include "_XMLDomWrapper.au3"
#include <Array.au3>

$sFile = "C:\TEMP\foldercolors.xml"
$ret = _XMLFileOpen ($sFile)    
        
For $i=1 to _XMLGetNodeCount("/foldercolors/path")
    $pathstring = _XMLGetValue("/foldercolors/path[" & $i & "]/dir/pathstring")
    If IsArray($pathstring) Then
        If NOT FileExists($pathstring[1]) Then
        $count = _XMLGetNodeCount("/foldercolors/path")
        Do 
        deletenode()
        $count = _XMLGetNodeCount("/foldercolors/path")
        Until $count = -1
        EndIf
    EndIf
Next

Func deletenode()
_XMLDeleteNode("/foldercolors/path[" & $i & "]")
EndFunc
Edited by will88

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  
Followers 0