Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 将数据提交到阵列以稍后提取_Android_Arrays_Getelementsbytagname - Fatal编程技术网

Android 将数据提交到阵列以稍后提取

Android 将数据提交到阵列以稍后提取,android,arrays,getelementsbytagname,Android,Arrays,Getelementsbytagname,因此,我有以下几点: NodeList nodeList = element.getElementsByTagName("rowset"); if (nodeList.getLength() > 0) { for (int i = 0; i < nodeList.getLength(); i++) { Element entry = (Element) nodeList.item(i); Element _titleE = (Eleme

因此,我有以下几点:

NodeList nodeList = element.getElementsByTagName("rowset");

    if (nodeList.getLength() > 0) {
     for (int i = 0; i < nodeList.getLength(); i++) {
      Element entry = (Element) nodeList.item(i); 

      Element _titleE = (Element) entry.getElementsByTagName("row").item(0);  
      Node _title = _titleE.getAttributes().getNamedItem("name");

      t1.setText(_title.getNodeValue());

     }
    }
NodeList NodeList=element.getElementsByTagName(“行集”);
if(nodeList.getLength()>0){
for(int i=0;i
我有以下XML布局:

<row name="" characterID="" corporationName="" corporationID="" />

(其中几行)

理想的方法是创建一个数组,对吗?然后从数组中调用数据

编辑: 我想做的是读取一个XML文件并存储值,以便以后可以访问它们,所以我假设理想的方法是使用数组?

(因为我的女朋友也叫jenny,我猜你想要什么)

如果您只想存储一个值,那么使用数组或ArrayList就可以了。如果需要存储行的所有4个给定属性,那么应该考虑创建一个包含这些值的类(称为MyRow)。然后,您可以将所有行放入一个具有类类型的ArrayList中

伪代码:

ArrayList<MyRow> myRowList = new ArrayList<MyRow>();
while reading each row
   MyRow row = new MyRow();
   row.mName = getAttributes().getNamesItem("name");
   row.mCharacterId = getAttributes().getNamesItem("characterID");
   // more setting...
}
ArrayList myRowList=new ArrayList();
读每行的时候
MyRow=新建MyRow();
row.mName=getAttributes().getNamesItem(“名称”);
row.mCharacterId=getAttributes().getNamesItem(“characterID”);
//更多设置。。。
}

下一次的最后一个提示:花点时间解释并详细说明下一个问题。这也会改善你得到的答案。

理想的做法是什么?