Ciao a tutti!
Senza dilungarmi troppo vi espongo subito il mio problema, in pratica ho un xml, del quale ora vi copio il codice:
<?xml version="1.0" encoding="UTF-8"?>
<scrapersresult>
<id>84829</id>
<urn_acct>200374274</urn_acct>
<original_legal_name>4D ENGINEERING SRL</original_legal_name>
<original_street_address>Via Rufelli 22</original_street_address>
<original_partita_iva>03869371009</original_partita_iva>
<original_pr_zipcode>00040</original_pr_zipcode>
<original_pr_state>RM</original_pr_state>
<legal_name>4d Engineering</legal_name>
<forma_giuridica></forma_giuridica>
<street_address>ALBANO LAZIALE (RM) (00041) c. Matteotti 69</street_address>
<street></street>
<partita_iva></partita_iva>
<company_city></company_city>
<cam_reg></cam_reg>
<company_country></company_country>
<company_province></company_province>
<company_postal_code></company_postal_code>
<company_industry>SOCIETÀ DI INGEGNERIA E CONSULENZA TECNICO ECONOMICA</company_industry>
<main_phone_number>06 9322616</main_phone_number>
<number_of_employes>51-150</number_of_employes>
<turnover_amount>da 250.001,00 a 500.000,00</turnover_amount>
<turnover_year></turnover_year>
<fundation_year>1990</fundation_year>
<email>info@4dengineering.com</email>
<fax>06 9322615</fax>
<web_site></web_site>
<turnover_currency>EUR</turnover_currency>
<owning_organization></owning_organization>
<datasource>"http://www.guidamonaci.it/ricerca/de...05525111"</datasource>
<first_name></first_name>
<last_name></last_name>
<job_title></job_title>
<work_phone>+39 06 9322616</work_phone>
<cell_phone></cell_phone>
<profile_street_address></profile_street_address>
<profile_city></profile_city>
<profile_country></profile_country>
<profile_postal_code></profile_postal_code>
<profile_datasource></profile_datasource>
<referent>referent@referent.it</referent>
<number_of_employes_from>51</number_of_employes_from>
<number_of_employes_to>150</number_of_employes_to>
<turnover_amount_from>250001</turnover_amount_from>
<turnover_amount_to>500000</turnover_amount_to>
<region>Lazio</region>
<file_uploaded_name>SAMPLE2.xlsx</file_uploaded_name>
<turnover_type>RANGE</turnover_type>
<descrizione></descrizione>
<company_industry_ibm></company_industry_ibm>
<note></note>
<ro></ro>
</scrapersresult>
Ho fatto il mio bean con i vari getter and setter ma ora volevo trovare una libreria o qualcosa che mi permettesse di riempire i campi con i valori dell'xml senza stare a settarli io uno a uno a mano... Ho trovato questo codice che in teoria doveva eseguire il tutto
public class XmlToBean {
public static void main(String[] args) throws FileNotFoundException {
try
{
XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(new FileInputStream("scrapersresult.xml")));
//
// Reads the next object from the underlying input stream.
//
XmlForm bean = new XmlForm();
bean = (XmlForm) decoder.readObject();
decoder.close();
}catch(FileNotFoundException e)
{
e.printStackTrace();
}
}
}
Ma invece ma da una serie di errori sull'apertura e la chiusura dei tag... Per ogni tag mi dice
Unrecognized openening/closing tag: scraperesult ...
Continuing...
ETC ETC per tutti i campi...
Non riesco a venirne a capo.. Qualche idea? Anche utilizzando altri metodi è![]()

Rispondi quotando