I tried for many hours and looked at all possible examples on Google, but I cannot figure out how to get attributes from this XML file using simplexml on Android.
XML file:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Service>
<Facture FactNo=""
NoAppel="6"
ProjDate="2012-04-01"
NomProj="MR. H. BLOOM"
AddProj="20, GARDEN ROAD"
VilleProj="WESTMOUNT, QC."
CPProj="" ContProj="M. BLOOM"
TelProj="(555) 555-9571"
SysMarque=""
SysMod=""
SysType=""
SysSerie=""
SysNo=""
SysTemp=""
Tension=""
Phase="0"
Halo="False"
POFact=""
NomFact=""
AdrsFact=""
VilleFact=""
CPFact=""
TelFact=""
FaxFact=""
Trouble=""
TbLock="False"
TDesc=""
TRec=""
Depl="False"
TM="False"
NoTM=""
TPA="False"
NoTPA=""
CS="False"
NoCS=""
Estim="False"
NoEstim=""
Proj="False"
NoProj=""
Term="True"
Incompl="False"
Garant="False"
NoGarant=""
Annexe="False"
NoAnnexe=""
NoContrat="00007"
MainDoeuvre="0,0000"
Materiel="0,0000"
SousTot=""
TPS="0,0000"
TPSTaux="0.05"
TVQ="0,0000"
TVQTaux="0.085"
Total="0,0000" />
<Pieces>
<Piece Qty="10" Desc="test" PO="12345678" PrixUnit="0.0000" Montant="0.0000" />
<Piece Qty="25" Desc="testitem2" PO="33333" PrixUnit="22.0000" Montant="220.0000" />
<Piece Qty="35" Desc="testitem3" PO="44444" PrixUnit="33.0000" Montant="440.0000" />
</Pieces>
<Techs>
<Tech Nom="Bobby" Reg="1" TD="2" Taux="3.5000" Montant="0.0000" Lock="False" Date="2012-04-01
10:49:00" />
</Techs>
<Sign />
<Pics />
</Service>
The XML file is a third party, so I cannot change it.
Service class (part only):
@ElementList(name="Piece", inline=true)
@Path("Pieces")
private List<PieceXML> pieces;
public List<PieceXML> getpieces()
{
return pieces;
}
Class for the play:
@Root(name="Piece")
public class PieceXML
{
@Attribute
private Double Qty;
@Attribute
private String Desc;
@Attribute
private String PO;
@Attribute
private Double PrixUnit;
@Attribute
private Double Montant;
...}
I really need to build an array of attribute values in Piece, but I really can't figure out how to do this. Any help would be greatly appreciated. Thanks in advance.
source
share