xml查询返回带有existnode筛选条件的节点值

wlp8pajw  于 2021-07-29  发布在  Java
关注(0)|答案(0)|浏览(151)

感谢您的支持。我有一个要求,如果存在一个特定的节点,我想返回特定的节点值。示例-对于下面的xml,我的输出将是2条记录,因为(jobsdata/joblist/jobdata/job/document)节点存在2次,返回的节点是(job/document/fileid和job/directoryid)。o/p-->100,d100 200,d200

<jobList>

    <jobData>

        <job>

            <name>JOBNAME10</name>
            <document>
                <fileID>100</fileID>
            </document>
            <directoryid>D100</directoryid>

            <schedule>

                <frequency>IMMEDIATE</frequency>

            </schedule>

            <targetType>host</targetType>

            <targets>

                <name>node100.localdomain</name>

                <type>host</type>

            </targets>

            <targets>

                <name>node200.localdomain</name>

                <type>host</type>

            </targets>

        </job>

    </jobData>

    <jobData>

        <job>

            <name>JOBNAME20</name>
            <document>
                <fileID>200</fileID>
            </document>
            <directoryid>D200</directoryid>

            <schedule>

                <frequency>REPEAT_BY_DAYS</frequency>

            </schedule>

            <status>ACTIVE</status>

            <targetType>host</targetType>

            <targets>

                <name>node300.localdomain</name>

                <type>host</type>

            </targets>

        </job>

    </jobData>

    <jobData>

        <job>

            <name>JOBNAME300</name>
            <directoryid>D300</directoryid>

            <schedule>

                <days>3</days>

                <days>5</days>

                <frequency>WEEKLY</frequency>

            </schedule>

            <targets>

                <name>node400.localdomain</name>

                <type>host</type>

            </targets>

        </job>

    </jobData>

</jobList>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题