I am quite new in Xml parsing. i am having a XMl
<company>
<account>
<id>8c98a6be</id>
<label>4356</label>
<reference>4356</reference>
</account>
<date>2012-06-05</date>
<advertisers>
<advertiser><id>7</id><name>ABC Telecom</name></advertiser>
<advertiser><id>106</id><name>ABC_Ozone</name></advertiser>
<advertiser><id>13</id><name>Acme Corp</name></advertiser>
</advertisers>
</company>
which i am parsing thru this code.
public class XMLParser {
public static void parseXML(String xmlValue) {
Dom.Document doc = new Dom.Document();
try {
doc.load(xmlValue);
DOM.XMLNode root = doc.getRootElement();
loadChilds(root);
} catch (System.XMLException e) {
System.debug( e.getMessage());
}
}
public static void loadChilds(DOM.XMLNode node) {
if (node.getNodeType() == DOM.XMLNodeType.ELEMENT) {
System.debug(node.getName()
'+'
node.getText());
}
for (Dom.XMLNode child: node.getChildElements()) {
loadChilds(child);
}
}
}
i want to create a list of List<advertiser__c>
. how do i parse it to achieve a list with all repeated advertiser with all other details i.e data , id , label,reference.