I'm trying to parse a simple xml file in my j2me application. But the parsing fails.
Anyone an idea, what I'm doing wrong?
Thanks,
rAyt
XML File
<companies>
<company CompanyId="6">
<CompanyName>Test Company 1</CompanyName>
<SapNumber>0</SapNumber>
<RootCompanyId>1</RootCompanyId>
<ParentCompanyId /> </company>
</companies>
Parser Snippet
KXmlParser parser = new KXmlParser();
parser.setInput(new InputStreamReader(new ByteArrayInputStream(input.getBytes())));
parser.nextTag();
parser.require(XmlPullParser.START_TAG, null, "companies");
while(parser.nextTag() == XmlPullParser.START_TAG)
{
Company temp_company = new Company();
parser.require(XmlPullParser.START_TAG, null, "company");
String CompanyID = parser.getAttributeValue(0);
temp_company.putValue("CompanyId", CompanyID);
while(parser.nextTag() == XmlPullParser.START_TAG)
{
if(parser.getName() == "CompanyName")
{
temp_company.putValue("CompanyName", parser.nextText());
}
}
parser.require(XmlPullParser.END_TAG, null, "company");
listCompany.put(CompanyID, temp_company);
}
parser.require(XmlPullParser.END_TAG, null, "elements");