i trying fetch below xml db using java method getting error
code used parse xml
documentbuilderfactory dbf = documentbuilderfactory.newinstance(); documentbuilder db = dbf.newdocumentbuilder(); inputsource = new inputsource(new bytearrayinputstream(cond.getbytes())); document doc = db.parse(is); element elem = doc.getdocumentelement(); // here expect series of <data><name>n</name><value>v</value></data> nodelist nodes = elem.getelementsbytagname("data"); tableid jobid = new tableid(_processinstanceid); job myjob = job.querybyid(_clientcontext, jobid, true); if (nodes.getlength() == 0) { log(level.debug, "no data found on condition xml"); } (int = 0; < nodes.getlength(); i++) { // loop through <data> in xml element datatags = (element) nodes.item(i); string name = getchildtagvalue(datatags, "name"); string value = getchildtagvalue(datatags, "value"); log(level.info, "userdata/value=" + name + "/" + value); myjob.setbulkuserdata(name, value); } myjob.save();
the data
<contactdetails>307896043</contactdetails> <contactname>307896043</contactname> <preferred_completion_date> </preferred_completion_date> <service_address>a-end address: 1st helierst helierjt2 3xp832the cables 1 poonha lanest helier je jt2 3xp</service_address> <serviceorderid>315473043</serviceorderid> <serviceordertypeid>50</serviceordertypeid> <custdesireddate>2013-03-20t18:12:04</custdesireddate> <orderid>307896043</orderid> <createwho>csmuser</createwho> <accountinternalid>20100333</accountinternalid> <serviceinternalid>20766093</serviceinternalid> <serviceinternalidresets>0</serviceinternalidresets> <primary_offer_name action='del'>mymobile blue £44.99 [12 month term]</primary_offer_name> <disc_reason action='del'>8</disc_reason> <sup_offer action='del'>80000257</sup_offer> <service_type action='del'>a-01-00</service_type> <priority action='del'>4</priority> <account_number action='del'>0</account_number> <offer action='del'>80000257</offer> <msisdn action='del'>447797142520</msisdn> <imsi action='del'>234503184</imsi> <sim action='del'>5535</sim> <ocb9_arm action='del'>false</ocb9_arm> <port_in_required action='del'> </port_in_required> <ocb9_mob action='del'>none</ocb9_mob> <ocb9_mob_bb action='del'> </ocb9_mob_bb> <ocb9_landline action='del'> </ocb9_landline> <ocb9_landline_bb action='del'> </ocb9_landline_bb> <contact_2> </contact_2> <acc_middle_name> </acc_middle_name> <marketcode>7</marketcode> <acc_last_name>port_out</acc_last_name> <contact_1> </contact_1> <acc_first_name>.</acc_first_name> <emaiid> </emaiid>
the error
org.apache.xerces.impl.io.malformedbytesequenceexception: invalid byte 1 of 1-byte utf-8 sequence.
i read in threads it's because of special characters in xml. how fix issue ?
how fix issue ?
read data using correct character encoding. error message means trying read data utf-8 (either deliberately or because default encoding xml file not specify <?xml version="1.0" encoding="somethingelse"?>
) in different encoding such iso-8859-1 or windows-1252.
to able advise on how should i'd have see code you're using read xml.
Comments
Post a Comment