Converting XML to CSV with xmlstarlet with no success

I have a XML document that is formatted as follows:

<?xml version="1.0" encoding="UTF-8"?>
<appname version="2.3">
  <system name="web host">
    <username><![CDATA[username1]]></username>
    <password><![CDATA[password1]]></password>
    <note><![CDATA[]]></note>
    <url><![CDATA[]]></url>
  </system>
  <system name="vendor name">
    <username><![CDATA[[email protected]]]></username>
    <password><![CDATA[password2]]></password>
    <note><![CDATA[]]></note>
    <url><![CDATA[]]></url>
  </system>
  <system name="vendor name 3">
    <username><![CDATA[[email protected]]]></username>
    <password><![CDATA[password3]]></password>
    <note><![CDATA[]]></note>
    <url><![CDATA[]]></url>
  </system>
<appname>

I am trying to use:

xmlstarlet \
  sel -T -t -m /root/system \
  -v "concat(@name,',',username,',',password,',',note,',',url)" \
  -n filename.xml

and I get:

failed to load external entity "concat(@name,',',username,',',password,',',note,',',url)-n"

I just want a tab delimited document from the current one so I can import it into another password manager. I have hundreds of entries I would really like to not have to retype.

Can anyone help?


Solution 1:

Using Xidel:

xidel -s vendor.xml -e "/appname/system/join((./@name, ./username/text(), ./password/text()), x:cps(9))"

Produces:

web host        username1       password1
vendor name     [email protected]      password2
vendor name 3   [email protected]      password3

Thanks to @Reino for trick to print TAB chars and arg placement. Tested quotes on cmd.exe and Cygwin bash.