It is necessary to deduce from the xml document only those texts that I need. The necessary data comes out only if I deduce somewhere from the middle then the initial lines also go out.

document.xml выглядит вот так(в оригинале внутри каждого <parent> по 100-200 <item>-ов. А <parent>-ов где то 150) <?xml version="1.0" encoding="UTF-8"?> <root> <parent> <item> ْтекст </item> <item> текст </item> <item> текст </item> </parent> <parent> <item> текст </item> <item> текст </item> </parent> <parent> <item> текст </item> <item> текст </item> <item> текст </item> </parent> </root> 

There are 2 variables int position and int currentLength , position indicates which <parent></parent> you need to select, if int position = 2 then you need to output <item> - s of the second <parent> The first <parent> with its internals is left and the following ones are also not output (3,4,5, etc., we do not output them. Only N2) .. and the currentLength it says how many <item> s are inside <parent> .

 class MyAsyncTask2 extends AsyncTask<Void,Void,Void>{ @Override protected Void doInBackground(Void... voids) { int cnt=0; try { XmlPullParser xpp = prepareXpp(); while (xpp.getEventType() != XmlPullParser.END_DOCUMENT){ switch (xpp.getEventType()){ case XmlPullParser.TEXT: Log.e("TEXT", xpp.getText() + " : count : " + cnt); break; case XmlPullParser.END_TAG: if(xpp.getName().equals("parent")){ cnt++; } break; } if(cnt>position){ break; } xpp.next(); } } catch (XmlPullParserException e) { } catch (IOException e) { } Log.e("currentLength", "currentLength = " + currentLength); return null; } } 

    0