mmsajid
10th December 2008 12:06 UTC
How can I search and delete the xml node
Hi, Iam wondering how can we accomplish the following in
NSIS. It would be great if some one can answer the below.
I have the following xml.
1. How can i search if a child node with "Item-2" is present
2. If present how can I delete the child node containing the same.
<Root>
<Children>
<Child>
<Name>
<![CDATA[Item -1]]>
</Name>
</Child>
<Child>
<Name>
<![CDATA[Item -2]]>
</Name>
</Child>
...
...
</Children>
</Root>
Thanks for reading my question.
Regards,
mmsajid
12th December 2008 14:52 UTC
Ok here is the code for searching and deleting.
------------------------------------------------------------
outFile "Testme.exe"
!include "logiclib.nsh"
!include "xml.nsh"
Section
${xml::LoadFile} "c:\Test.xml" $0
${Do}
${xml::FindNextElement} "Child" $0 $2
${If} $2 == -1
${xml::FindCloseElement}
${ExitDo}
${EndIf}
${xml::FirstChildElement} "Name" $8 $9
${xml::GetText} $8 $9
${If} $8 == 'Item -2'
${xml::Parent} $0 $1
${xml::RemoveNode} $0
${xml::SaveFile} "" $0
${ExitDo}
${EndIf}
${Loop}
SectionEnd
------------------------------------------------------------