Wiki source for CommandXdelete


Show raw source

=====Command xdelete=====


====Name====
**xdelete** Deletes nodes (element,text,attribute) from an XML document


====Synopsis====
**xdelete** [options]

Deletes all nodes matching the expression given

====Options====

||-e,-xpath xpath-expr||xpath expression||
||-m,matches matches-expr||XSLT matches expression||


====Description====

xdelete is a simple front end to the [[CommandXed xed]] command which deletes all matching nodes, expressed as either a XSLT matches expression or an xpath expression.


Example: delete the path attribute from all file elements from xls
%%
xls | xdelete -m @path

%%

Result (when run on root xmlsh directory)

%%(xml)
<dir>
<file name="README.txt"/>
<file name="_dist"/>
<file name="_out"/>
<file name="bin"/>
<file name="build-lib"/>
<file name="build.xml"/>
<file name="doc"/>
<file name="lib"/>
<file name="license.txt"/>
<file name="notices"/>
<file name="play"/>
<file name="samples"/>
<file name="schemas"/>
<file name="src"/>
<file name="test"/>
<file name="unix"/>
<file name="win32"/>
<file name="xmlsh.log"/>
</dir>
%%


====Implementation====
The xdelete command is implemented as a built-in xsh script

%%(sh)
xed -d "$@"
%%


====Return Value====
Returns 0 if the command executed successfully, 1 if there was an error.
----
[[Commands]]
[[CommandXed xed]]
[[CommandXAddattribute xaddattribute]]
[[CategoryCommands]]
[[CommandsPosix]]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki