<opDetail>
<recordInfo>
<fieldInfo>
<fieldChName>告警流水号</fieldChName>
<fieldEnName>alarmId</fieldEnName>
<fieldContent>GJ_2816071613_352385154_2970760107_588354443</fieldContent>
</fieldInfo>
<fieldInfo>
<fieldChName>告警ID</fieldChName>
<fieldEnName>alarmStaId</fieldEnName>
<fieldContent>2014070200101</fieldContent>
</fieldInfo>
</recordInfo>
</opDetail><opDetail>
<recordInfo>
<alarmId>GJ_2816071613_352385154_2970760107_588354443</alarmId>
<alarmStaId>2014070200101</alarmStaId>
</recordInfo>
</opDetail><opDetail>
<recordInfo>
{
for $a in //fieldInfo
return <name>{$a/fieldEnName/text()}</name>
}
</recordInfo>
</opDetail><opDetail><recordInfo><name>alarmId</name><name>alarmStaId</name></recordInfo></opDetail>
<opDetail>
<recordInfo>
{
for $a in //fieldInfo
return <name fieldChName="{$a/fieldChName/text()}">{$a/fieldEnName/text()}</name>
}
</recordInfo>
</opDetail><opDetail><recordInfo><name fieldChName="告警流水号">alarmId</name><name fieldChName="告警ID">alarmStaId</name></recordInfo></opDetail>
element html {
element h1 { "This is a Test"}
}<html><h1>This is a Test</h1></html>
element opDetail {
for $a in //fieldInfo
return element {$a/fieldEnName/text()} {$a/fieldContent/text()}
}<opDetail><alarmId>GJ_2816071613_352385154_2970760107_588354443</alarmId><alarmStaId>2014070200101</alarmStaId></opDetail>
element opDetail {
for $a in //fieldInfo
return element {concat("ele",$a/fieldEnName/text())} {$a/fieldContent/text()}
}<opDetail><elealarmId>GJ_2816071613_352385154_2970760107_588354443</elealarmId><elealarmStaId>2014070200101</elealarmStaId></opDetail>
XQuery元素构造,你知道多少?,布布扣,bubuko.com
原文地址:http://blog.csdn.net/vjrmlio/article/details/36432127