xmlstarlet returning the value of the first node only

最后都变了- 提交于 2019-12-13 07:39:44

问题


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>

来源:https://stackoverflow.com/questions/25252040/xmlstarlet-returning-the-value-of-the-first-node-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!