function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ram Manohar GRam Manohar G 

DOM XML Parsing Wrapper Structure

Hi,

Can anyone tell me which is the best structure of wrapper class to parse this XML. I want to keep this data in to wrapper. I am writing this way.

<Body>		
		<sampleresponse>
					
					<ns:InteranetData>                
						<networkAvailbility>Y</networkAvailbility>
						<Country>Brazil</Country>
						<RiskLevel>3</RiskLevel>
            			<netstat>                        
               			   <bandwidth>100</bandwidth>
               			   <type>BroadBand</type>
						</netstat>
						<netstat>                 
               				<bandwidth>70</bandwidth>
               				<type>Wireless</type>
						</netstat>
					</ns:InteranetData>
					
					<ns:NetworkProviders>
						<ns:AON>
							<ns1:Metroavailability>true</ns1:Metroavailability>
							<ns1:minPay>600</ns1:minPay>
							<ns1:maxPay>5000</ns1:maxPay>
							<ns1:areacode>S4</ns1:areacode>
							<ns1:postcode/>
						</ns:AON>
						<ns:ExcelBB>
							<ns1:Metroavailability>true</ns1:Metroavailability>
							<ns1:monthlyChargeble>8000</ns1:monthlyChargeble>
							<ns1:minPay>3000</ns1:minPay>
							<ns1:maxPay>9000</ns1:maxPay>
							<ns1:areacode>S1</ns1:areacode>
						</ns:ExcelBB>
					</ns1:NetworkProviders>
					
	    </sampleresponse>
	    </Body>	
		
  public class InteranetData
  {
    private String networkAvailbility{get;set;}
    private String Country{get;set;}
    private String RiskLevel{get;set;}
    public List<netstat> onnetAvail=new list<netstat>();

  }
  
  public  class netstat
  {
    public String bandwidth;
    public String type;  
  }
  
  public class NetworkProviders
  {
     List<AON> alist =new List<AON>;
      List<ExcelBB> Elist =new List<ExcelBB>;	 
   
  }
   public  class AON
  {
    public String Metroavailability;
    public String monthlyChargeble;  
  }
   public  class ExcelBB
  {
    public String Metroavailability;
    public String monthlyChargeble;  
  }

 

AshlekhAshlekh
Hi,

Here is information about XML parsing.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_xml_dom.htm

You have to use DOM classes to parse the node of XML.

-Thanks
Ashlekh Gera