我从 PDF 中提取了如下字符串格式的数据。(请注意不均匀的间距和换行符)。
Virtual Salary 25,100.00 EIS EE Contr. 7.90
Virtual Car Allowance 1,600.00 EPF Employee Contr. 2,937.00
Payment Received(Oversea) 4,265.01 SOCSO Employee Contr. 19.75
如何将此字符串转换为 XML,如下所示。
public void testMethod()
{
String extractedTestFromPDF=
" Virtual Salary 25,100.00 EIS EE Contr. 7.90\n"+
"\t Virtual Car Allowance 1,600.00 EPF Employee Contr. 2,937.00\n"+
" Payment Received(Oversea) 4,265.01 SOCSO Employee Contr. 19.75\n";
}
期望 XML:
<xml>
<Data>
<Allowance>Virtual Salary</Allowance>
<Allowance_Amount>25,100.00</Allowance_Amount>
</Data>
<Data>
<Allowance>EIS EE Contr.</Allowance>
<Allowance_Amount>7.90</Allowance_Amount>
</Data>
<Data>
<Allowance>Virtual Car Allowance</Allowance>
<Allowance_Amount>1,600.00</Allowance_Amount>
</Data>
...
</xml>
湖上湖
相关分类