Hi,
I have an XML file with a simple structure:
<xml>
<test>
<user>John</user>
<id>1</id>
</test>
</xml>
I would like to remove the whole id element from the xml leaving it in the following format.
<xml>
<test>
<user>John</user>
</test>
</xml>
How can I achieve this?
Regards,
T.
Remove XML file element
-
- Site Admin
- Posts: 5361
- Joined: Sun Aug 22, 2010 4:28 am
Re: Remove XML file element
Dear tzachk,
supposing you have;
To remove all <Section Name="Connection"> elements, you should use;
To remove all <Users> elements, you should use;
Hope this helps you.
Regards
supposing you have;
Code: Select all
<ApplicationSettings>
<Section Name="General">
<Key Name="RootPath" Value="C:\mytest\sales" />
<Key Name="Images" Value="\Jpg\" />
</Section>
<Section Name="Connection">
<Key Name="Server" Value="SERVER04" />
<Key Name="SqlDatabase" Value="PM4Uster" />
<Key Name="TrustedConnection" Value="0" />
</Section>
<Section Name="Agent">
<Key Name="UseAgent" Value="0" />
</Section>
<Users>
<key id="1" />
</Users>
</ApplicationSettings>
To remove all <Section Name="Connection"> elements, you should use;
Code: Select all
~InstallAware Clipboard Data~
~Edit XML File~
~{EB2F4EE3-D72D-46C3-A979-968DE0451E21}~
~C:\XMLFile2.xml~
~UTF-8~
~0~
~ApplicationSettings\Section~
~~
~"Name,Connection"~
~3~
~FALSE~
~FALSE~
~TRUE~
To remove all <Users> elements, you should use;
Code: Select all
~InstallAware Clipboard Data~
~Edit XML File~
~{7CB09363-E6EC-4173-8EB1-3FDF97531DA9}~
~C:\XMLFile2.xml~
~UTF-8~
~0~
~ApplicationSettings\Users~
~~
~~
~3~
~TRUE~
~FALSE~
~TRUE~
Hope this helps you.
Regards
Francesco Toscano
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Re: Remove XML file element
Hi Francesco,
Thanks for your reply. I already tried it but it doesn't work for me. I did some testing and found out that my issue happens because of a minus character '-' between elements.
I've included your xml schema while changeing the value in the key element under Users.
Try the following to replicate:
Try to remove the ApplicationSettings\Users element. It shall fail. I tested this xml schema against w3 validator and it passes.
Please let me know what can be done.
Tzach
Thanks for your reply. I already tried it but it doesn't work for me. I did some testing and found out that my issue happens because of a minus character '-' between elements.
I've included your xml schema while changeing the value in the key element under Users.
Try the following to replicate:
Code: Select all
<ApplicationSettings>
<Section Name="General">
<Key Name="RootPath" Value="C:\mytest\sales"/>
<Key Name="Images" Value="\Jpg\"/>
</Section>
<Section Name="Connection">
<Key Name="Server" Value="SERVER04"/>
<Key Name="SqlDatabase" Value="PM4Uster"/>
<Key Name="TrustedConnection" Value="0"/>
</Section>
<Section Name="Agent">
<Key Name="UseAgent" Value="0"/>
</Section>
<Users>
<key>-</key>
</Users>
</ApplicationSettings>
Try to remove the ApplicationSettings\Users element. It shall fail. I tested this xml schema against w3 validator and it passes.
Please let me know what can be done.
Tzach
-
- Site Admin
- Posts: 5361
- Joined: Sun Aug 22, 2010 4:28 am
Re: Remove XML file element
Dear Tzach,
unfortunately, our command can't be used with that element ... you may try to read the entire XML file using "Read from Text File" and then, to parse its content in order to remove that element. Finally you can save it using "Write to Text File" command.
Hope this helps you.
Regards
unfortunately, our command can't be used with that element ... you may try to read the entire XML file using "Read from Text File" and then, to parse its content in order to remove that element. Finally you can save it using "Write to Text File" command.
Hope this helps you.
Regards
Francesco Toscano
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Re: Remove XML file element
Hi Francesco.
This issue needs to be resolved as it prevents altering XML files properly.
Regards,
Tzach
This issue needs to be resolved as it prevents altering XML files properly.
Regards,
Tzach
Who is online
Users browsing this forum: Majestic-12 [Bot] and 134 guests