我已经尝试了几个小时来附加三个 NodeList 并且失败了。你能帮我么?
我制作了以下代码:
NodeList nList = root.getElementsByTagName("res");
NodeList nList2 = root.getElementsByTagName("agr");
NodeList nList3 = root.getElementsByTagName("rag");
NodeList allNodes = appendNodeLists(nList, nList2, nList3);
和 appendNodeLists 方法:
public static NodeList appendNodeLists(NodeList a, NodeList b, NodeList c)
{
NodeList nList;
int aSize = a.getLength();
int bSize = b.getLength();
int cSize = c.getLength();
if(aSize>0)
{
for (int i = 0; i < aSize; i++)
nList.item(i) = a.item(i); //Error in this line
}
if(bSize>0)
{
for (int i = 0; i < bSize; i++)
nList.item(aSize+1+i) = b.item(i); //Error in this line
}
if(cSize>0)
{
for (int i = 0; i < bSize; i++)
nList.item(aSize+bSize+1+i) = c.item(i); //Error in this line
}
return nList;
}
我究竟做错了什么?我无法附加 3 个 NodeList,我似乎无法弄清楚原因。
顺便说一句,我在 3 行中有相同的错误:“意外类型 - 所需变量 - 找到值”。为什么会这样?