【发布时间】:2019-04-19 05:56:30
【问题描述】:
您好,我有一个如下的 xml:
> <body>
> <p>
>
> <xxx>
> <txt>{{<txt>
> </xxx>
> <Err type="Start"/>
> <xxx>
> <txt>f</txt>
> </xxx>
> <xxx>
> <txt>irst_name</txt>
> </xxx>
> <Err type="End"/>
> <xxx>
> <txt>}}</txt>
> </xxx>
> <p> </body>
所以我试图在
<Err type="Start"/> .... <Err type="End"/>
然后提取txt节点值得到“firstName”的输出
这是我目前所拥有的,但在此之后有点失落,请帮助。
xml = $(mainXMl).find('p')
$(xml).each(function(wPrgs){
var parentEle = $(xml[wPrgs]).find('Err')
$(parentEle).each(function(childEle){
$.each(this.attributes, function(i, attrib) {
if(attrib.name === "type" && attrib.value === "Start"){
var end= childEle===parentEle.length-1 ? parentEle.nextSibling : parentEle[childEle+1];
// what goes here ?????
}
});
});
});
});
【问题讨论】:
标签: javascript jquery xml-parsing siblings