用于遍历的 XSLT 代码 [英] XSLT code for traversal

查看:21
本文介绍了用于遍历的 XSLT 代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要打印两个不同父节点的第一个子节点.我在 XML 中有两个节点,如下所示.我只添加了我的 xml 代码的一部分:

I have requirement to print the first child node of two different parent nodes. I have two nodes in XML as below. I have added only a part of my xml code:

<UserValue title="project_variants" value="">
    <UserList id="id19" type="list">
    <Item value="LTD3,A"></Item>
    <Item value="LTD4,A"></Item>
    <Item value="PRODUCTION,B"></Item></UserList>
</UserValue>
<UserValue>
<UserList id="id11" type="list">
    <Item value="1 EACH"></Item>
    <Item value="2 EACH"></Item>
    <Item value="3 EACH"></Item>
</UserList>

预期输出:

LTD3 A 1 个

LTD4 A 2 个

生产 B 3 个

请帮帮我

推荐答案

您发布的 xml 似乎无效假设xml是这样的

The xml you have posted seems to be invalid Assuming the xml is like this

<UserValue title="project_variants" value="">
<UserList id="id19" type="list">
    <Item value="LTD3,A"></Item>
    <Item value="LTD4,A"></Item>
    <Item value="PRODUCTION,B"></Item>
</UserList>

<UserList id="id11" type="list">
    <Item value="1 EACH"></Item>
    <Item value="2 EACH"></Item>
    <Item value="3 EACH"></Item>
</UserList>
</UserValue>

你可以试试这样的使用 for-each 迭代第一组维护一个值等于当前位置的变量{使用 for-each 迭代第二组并选择位置等于上述循环中定义的 var 的节点}

You can try something like this iterate on first group using for-each maintain a variable with value equal to current position { iterate on second group using for-each and select the node with position equal to the var defined in the above loop }

这篇关于用于遍历的 XSLT 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆