-->

xmlstarlet returning the value of the first node o

2019-09-19 08:14发布

问题:

When running like this

$ xmlstarlet sel -t -v '//department[@id="123879"]/user/@name' -n file.xml 

it returns only the first user's name T:106603 and an empty line.

Here is the related XML code inside a file called file.xml (for testing purposes):

<config name="department" version="1.11">
     <xad version="1459" nocheckoutver="1701">
        <!-- ... -->
        <department name="/fighters" id="123879" group="channel" case="none" use="no">
            <replication region="4334">
                <options index_name="index.html" listing="0" sum="no" allowed="no" />
                <!-- ... -->
            </replication>
            <target prefix="http" suffix=".net" />
            <!-- ... -->
            <user name="T:106603" />
            <user name="T:123879" />
            <user name="test" />
            <user name="ele::123456" />
            <user name="company-temp" />
            <user name="companymw2" />
            <user name="bird" />
            <user name="coding11" />
            <user name="plazamedia" />
            <allow go="123456=abcdefghijklmnopqrstuvwxyz" />
            <!-- ... -->
        </department>
        <department name="/dancers" id="876543" group="floor" case="yes" use="no">
            <!-- ... -->
        </department>
    <!-- ... -->
    </xad>
</config>