<?xml version="1.0" encoding="UTF-8"?>
<rows>
<row>
<c n="ColorName">Cyan</c>
<c isNull="1" n="ColorType"/>
<c isNull="1" n="ColorBook"/>
<c isNull="1" n="SpotFunction"/>
<c n="Angle">45.0</c>
</row>
<row>
<c n="ColorName">HG8-Black</c>
<c isNull="1" n="ColorType"/>
<c n="ColorBook">designer</c>
<c n="SpotFunction">RY</c>
<c n="Angle">45.0</c>
</row>
</rows>
I have this structure and I need to get some values with this XPath:
/rows/row/c[3]/text()
My problem is that sometimes I have this isNull="1"
attribute and I get an error because there is no value. It is possible to ignore the line when there is no value?
请尝试以下操作,以避免匹配具有isNull
属性的c
节点:
/rows/row/c[3][not(@isNull)]/text()
使用此XPath表达式:
/rows/row/c[3][@isNull]/text()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.