如何将节点数组捕获到属性 [英] how to catch an array of nodes to a property

查看:20
本文介绍了如何将节点数组捕获到属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我如何将一组元素访问到一个属性.

Can any one please let me know how can I access an array of elements to a property.

例如:我有一个如下所述的 XML

For example: I have an XML as said below

<a>
 <x>1</x>
 <x>2</x>
 <x>3</x>
 <x>4</x>
</a>

我希望我的属性设置如下:

I want my property to be set as shown below:

 <x>1</x>
 <x>2</x>
 <x>3</x>
 <x>4</x>

当我尝试使用属性类型设置为 OM 元素或字符串的//x 访问时,我在我的属性中没有看到预期的结果.

when I try to access using //x with property type set to OM element or String I don't see the result as expected in my property.

任何人都可以指导我使用正确的 xpath 来查看所需的结果吗?

Can any one please direct me with the right xpath to be used to see the desired outcome ?

推荐答案

您应该能够为此使用//a/child::node() XPath.

You should be able to use //a/child::node() XPath for this.

请参考 XPath 获取所有子节点(元素、评论和文本)没有父元素

希望这有帮助!!

/哈莎娜

这篇关于如何将节点数组捕获到属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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