Jump to content

XLM read value and delete


AlbatorV
 Share

Recommended Posts

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>
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...