1

I want to read this xml file with XMLPullParser on android but when it comes to KeyValues part its throw exception, because tag names are not same in model. Tags are user-specified, every time KeyValues part have different name. how can I read this values?

<Shot>
<ShotGUID>1</ShotGUID>
<Title>aaa</Title>
<Group>bbb</Group>
<SGroup>ccc</SGroup>
<StartTime>00:00:00.00</StartTime>
<EndTime>00:00:00.00</EndTime>
<FileName>110.jpg</FileName>
<Dscp></Dscp>
  <KeyValues>           
     <name>ddd</name>
     <family>eee</family>
     <date>20.3</date>
  </KeyValues>
</Shot>
<Shot>
<ShotGUID>2</ShotGUID>
<Title>qqq</Title>
<Group>www</Group>
<SGroup>rrr</SGroup>
<StartTime>12:00:00.00</StartTime>
<EndTime>13:00:00.00</EndTime>
<FileName>20.jpg</FileName>
<Dscp>hello</Dscp>
  <KeyValues>           
     <email>example@yahoo.com</email>
     <index>mmm</index>
     <years>562</years>
     <factory>nnn</factory>
  </KeyValues>
</Shot>
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Ali Elahi
  • 131
  • 1
  • 10

1 Answers1

0

in key values use this

case "email": 
String a = parser.nextText();
break;
case "index":
String b = parser.nextText();
break;
case "years":
String c = parser.nextText();
break;
case "factory":
String d = parser.nextText();
break;
case "name":
String e = parser.nextText();
break;
case "family":
String f = parser.nextText();
break;
case "date":
String g = parser.nextText();
break;

All modes that your file may contain should be written and null when some of them may not exist.