![]() |
#1 |
Junior Member
Join Date: Nov 2021
Posts: 8
|
Edit attributes in an XML with nsisXML by Wizou
I can't figure it out.
I try to modify an XML, but I get lost when finding the issue why it's not working. I have a file "foo.xml" HTML Code:
<global> <colors lava="orange" sky="blue" > </colors> </global> HTML Code:
<global> <colors lava="orange" sky="cyan" earth="brown" > </colors> </global> This is how my NSIS code looks like: code: I haven't found any information in the documentation how to overwrite, add, or remove attributes with their values. Do I have to remove entire nodes, and append them again in the end? |
![]() |
![]() |
![]() |
#2 |
Junior Member
Join Date: Nov 2021
Posts: 8
|
I think nsisXML by Joel will be the easier solution to my problem.
code: The simpliest way would be just to add the attributes, and hoping the old ones will be overwritten. But knowing life, I probably have to check the attribute to see if it exists, then eventually remove it, and then add new attributes: (Check if "sky" and "earth" exist, if they exist - remove them, create new attributes "sky" and "earth" with new values) |
![]() |
![]() |
![]() |
#3 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,457
|
The Wizou plugin uses MSXML and MSDN says: "Sets or updates the supplied attribute node on this element"
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#4 |
Junior Member
Join Date: Nov 2021
Posts: 8
|
I got it.
This in nsisXML by Wizou should be written in an other way, so it would work. code: But it didn't work for me. But this below did work, in nsisXML by Joel. Last time updated in 2009. code: I didn't have to remove anything. There are no clones of attributes, it just works, and looks simple. If you have any ideas how the Wizous code should look like, please post your example. |
![]() |
![]() |
![]() |
#5 | |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,457
|
Quote:
PHP Code:
IntOp $PostCount $PostCount + 1 |
|
![]() |
![]() |
![]() |
#6 |
Junior Member
Join Date: Nov 2021
Posts: 8
|
Ah, yes. I forgot to save the file properly.
nsisXML::save requires an argument. The downside of the two nsisXML versions is, that the structure is being rebuilt. This is the result I was trying to achieve: HTML Code:
<global> <colors lava="orange" sky="cyan" earth="brown" > </colors> </global> HTML Code:
<global> <colors lava="orange" sky="cyan" earth="brown"> </colors> </global> |
![]() |
![]() |
![]() |
#7 | |
Junior Member
Join Date: Nov 2021
Posts: 8
|
Quote:
|
|
![]() |
![]() |
![]() |
#8 | |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,457
|
Quote:
PHP Code:
IntOp $PostCount $PostCount + 1 |
|
![]() |
![]() |
![]() |
|
Tags |
attribute, joel, wizou, xml |
Thread Tools | Search this Thread |
Display Modes | |
|
|