I read an Xml file with XmlPullParser but it gives Exception (unterminated entity ref (position:TEXT @817:4 in java.io.InputStreamReader@4cb5258) when it comes to Dscp .
i reader another shot like this before this shot every thing is ok until this one. when i remove Dsec from xml every thing is ok and i read all xml file. when i read xml with Dsec i have exception in this shot
The shot before is like this shot
<Shot>
<ShotGUID>59AA1C15D3384B5691FBFB40B0FE38BD</ShotGUID>
<Title>##Step 2-Categories of Projects</Title>
<StartTime>00:00:40.00</StartTime>
<EndTime>00:00:00.00</EndTime>
<FileName>Shot0042.jpg</FileName>
<Dscp>Step 2-Categories of Projects
Aggregate project plan identifies four separate categories of projects:
Derivative projects … those that are only incrementally different from existing offerings
Platform projects … major departures from existing offerings … the next generation
Breakthrough projects … involving a newer technology … possibly a “disruptive” technology
R&D projects … “blue sky” or visionary endeavors
</Dscp>
<Footer></Footer>
</Shot>
And this is my code :
XmlPullParserFactory parserFactory;
parserFactory = XmlPullParserFactory.newInstance();
XmlPullParser parser = parserFactory.newPullParser();
ByteArrayInputStream byteArrayInputStreamXmlData = new ByteArrayInputStream(bufferXMLData);
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
parser.setInput(byteArrayInputStreamXmlData, "UTF-8");
List<PageModel> pages = new ArrayList<>();
int eventType = parser.getEventType();
PageModel current = null;
while (eventType != XmlPullParser.END_DOCUMENT) {
String eltName = null;
switch (eventType) {
case XmlPullParser.START_TAG:
eltName = parser.getName();
if (eltName.equals("Shot")) {
current = new PageModel();
pages.add(current);
} else if (current != null) {
switch (eltName) {
case "ShotGUID":
current.setShotGUID(parser.nextText());
break;
case "StartTime":
current.setStartTime(parser.nextText());
break;
case "EndTime":
current.setEndTime(parser.nextText());
break;
case "FileName":
current.setFileName(parser.nextText());
break;
case "Dscp":
current.setDscp(parser.nextText());
case "Footer" :
current.setFooter(parser.nextText());
break;
}
}
break;
}
eventType = parser.next();
}
After much research I realized that I couldn't use the & character in the Dscp Value and I need to use alternate codes.
What are the special characters in XML?
< (<), & (&), > (>), " ("), and ' (').