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
Sid ChildersSid Childers 

How to test my XML file for null child nodes?

I've created a test method that checks to see if the XML document is null.  However, my test coverage is still not passing even with SeeAllData = true.  Here's the test method I'm currently using:
string XMLStr = '';
     XMLStr = '<?xml version="1.0" encoding="UTF-8"?><IFX><CreditSvcRs><LoanAppSvcRs><Routing Transaction="LoanAppRs,LoanAppRq"><From><IDs><ID Type="DealerID">40511</ID><ID Type="EvaluatorID">91</ID><ID Type="OrigenateRefNumber">2681674</ID><ID Type="Source">WEBSITE</ID><ID Type="Network">WEBSITE</ID><ID Type="ApplicationNumber">1297043</ID><ID Type="DecisionID">3084818</ID></IDs><HostNameBack>Origenate</HostNameBack><RemoteRefNumber>157277</RemoteRefNumber></From><To><IDs><ID Type="DecisionID">3084818</ID><ID Type="EvaluatorID">0</ID><ID Type="ApplicationNumber" /></IDs><Destination>defined-by-gateway</Destination><LocalRefNumber>157277</LocalRefNumber></To><Processing><Process Type="Trans-type">LOAD</Process></Processing></Routing><LoanAppRs PaymentCall="True"><Decision Category="Analyst" DecisionRefID="3084818" Evaluator="91" IndividualType="Applicant" Status="APPROVE"><Analyst><AnalystName>Tereance  Dennis</AnalystName><ContactInfo><Phone><AreaCode>888</AreaCode><Exchange>696</Exchange><LastPart>8461</LastPart><Extension>38581</Extension></Phone></ContactInfo><AnalystID>TDENNIS</AnalystID></Analyst><Comments><Comment>Fin $15200</Comment></Comments><Payment>293.03</Payment><CustomerRate>11.3</CustomerRate><Date><Year>2014</Year><Month>04</Month><Day>18</Day><Hour>11</Hour><Minute>45</Minute><Second>47</Second></Date><Term>72</Term><ApprovedAmount>15200</ApprovedAmount><RepaymentType>Installment</RepaymentType><BuyRate>0</BuyRate><Grade>F1</Grade><BBCLAmortTerm>0</BBCLAmortTerm><DealerIncentive>0</DealerIncentive><PaymentFrequency>Monthly</PaymentFrequency><StandardStips /><OutsideSource /><LTV>999.99</LTV><ApprovedDeposit>0</ApprovedDeposit><Stipulations><Stipulation><CheckListItem>True</CheckListItem><Required>True</Required><Text>PROOF OF INCOME, RESIDENCE, INSURANCE, DRIVERS LICENSE AND 2 PERSONAL REFERENCES</Text><StipulationType>Predefined</StipulationType></Stipulation><Stipulation><CheckListItem>True</CheckListItem><Required>True</Required><Text>WE WILL FINANCE 100% OF RETAIL VALUE + SERVICE CONTRACT UP TO APPROVED AMOUNT FINANCED</Text><StipulationType>Predefined</StipulationType></Stipulation></Stipulations><Finance><Term>0</Term><FinancedFees><FinancedFee Type="35"><Amount>0</Amount></FinancedFee><FinancedFee Type="36"><Amount>0</Amount></FinancedFee><FinancedFee Type="53"><Amount>0</Amount></FinancedFee><FinancedFee Type="54"><Amount>0</Amount></FinancedFee><FinancedFee Type="55"><Amount>0</Amount></FinancedFee><FinancedFee Type="84"><Amount>0</Amount></FinancedFee><FinancedFee Type="99"><Amount>0</Amount></FinancedFee><FinancedFee Type="158"><Amount>0</Amount></FinancedFee></FinancedFees></Finance><DecisionRules><DTIPTILTV><Category>APP</Category><PolicyDecision>P</PolicyDecision><Triggered>False</Triggered><Value>49.91</Value><Type>DTI</Type></DTIPTILTV><DTIPTILTV><Category>APP</Category><Triggered>False</Triggered><Value>999.99</Value><Type>LTV</Type></DTIPTILTV><DTIPTILTV><Category>APP</Category><PolicyDecision>P</PolicyDecision><Triggered>False</Triggered><Value>13.95</Value><Type>PTI</Type></DTIPTILTV></DecisionRules></Decision><Individuals><Individual IndividualType="Applicant"><Score>482</Score></Individual></Individuals></LoanAppRs></LoanAppSvcRs></CreditSvcRs><CreditSvcRq><LoanAppSvcRq><Routing><From><IDs><ID Type="EvaluatorID">91</ID><ID Type="OrigenateRefNumber">2681674</ID><ID Type="Source">WEBSITE</ID></IDs><RemoteRefNumber>157277</RemoteRefNumber></From></Routing><LoanAppRq PaymentCall="True" Personal="True" Type="Finance"><Summary MissingInfo="False" PaperContract=""><ProductType>Direct Auto Retail</ProductType><TaskGroup>CONTRACTADMIN</TaskGroup><InitiationDate><Date><Year>2014</Year><Month>04</Month><Day>18</Day></Date></InitiationDate><LoanPurpose>Purchase Automobile</LoanPurpose><CallBureau>True</CallBureau><ReceiptDate><Date><Year>2014</Year><Month>04</Month><Day>18</Day><Hour>11</Hour><Minute>35</Minute><Second>45</Second></Date></ReceiptDate><MostRecentGrade>F1</MostRecentGrade><BookingStatus>1</BookingStatus><AppStatus>17</AppStatus><LastAccessDate><Date><Year>2014</Year><Month>04</Month><Day>18</Day></Date></LastAccessDate><DecisionStatus>APPROVE</DecisionStatus><TaskDesc>PURCHASE OUTBOUND</TaskDesc></Summary><Collateral Type="Auto"><CollateralInfo Condition="Used" IncludeInLTV="True" New="False" Primary="True"><Specifications><Specification Name="AutomaticTransmission" /><Specification Name="Make">Other</Specification><Specification Name="Diesel" /><Specification Name="ValueGuide">Manual</Specification><Specification Name="TotalRetailValue">0</Specification></Specifications></CollateralInfo></Collateral><Finance><CashPrice>0</CashPrice><SalesTax>0</SalesTax><Requested><Rate>18.95</Rate><Term>0</Term><Payment>0</Payment><PaymentMethod>Installment</PaymentMethod><PaymentFrequency>Monthly</PaymentFrequency><Amount>0</Amount><FixedPaymentMethod>1</FixedPaymentMethod><IndexType>0</IndexType><IndexRate>0</IndexRate><Margin>0</Margin></Requested><TradeInLastFinanced>False</TradeInLastFinanced><NetTradeIn>0</NetTradeIn><TotalFinancedFees>0</TotalFinancedFees><LastFinanced>False</LastFinanced><TotalInterestCost>0</TotalInterestCost><Program>Dealer Purchase</Program><HMDAEligibleProgram>False</HMDAEligibleProgram><TotalPriceAdjustments>0</TotalPriceAdjustments><Closing><FirstPaymentDate><Date><Year>2014</Year><Month>06</Month><Day>02</Day></Date></FirstPaymentDate></Closing><FinancedFees><FinancedFee Type="35"><Amount>0</Amount><FeesDesc>GAP Fee</FeesDesc><FinPoc>Y</FinPoc><Include>True</Include><LenderAmt>0</LenderAmt><BorrowerAmt>0</BorrowerAmt><OtherAmt>0</OtherAmt><PPFC>False</PPFC><FlatFee>False</FlatFee><PaidBy>B</PaidBy><AmtFinFlg>False</AmtFinFlg><ReqAmtFlg>True</ReqAmtFlg></FinancedFee><FinancedFee Type="36"><Amount>0</Amount><FeesDesc>Misc</FeesDesc><FinPoc>Y</FinPoc><Include>True</Include><LenderAmt>0</LenderAmt><BorrowerAmt>0</BorrowerAmt><OtherAmt>0</OtherAmt><PPFC>False</PPFC><FlatFee>False</FlatFee><PaidBy>B</PaidBy><AmtFinFlg>False</AmtFinFlg><ReqAmtFlg>True</ReqAmtFlg></FinancedFee><FinancedFee Type="53"><Amount>0</Amount><FeesDesc>Service Contract</FeesDesc><FinPoc>Y</FinPoc><Include>True</Include><LenderAmt>0</LenderAmt><BorrowerAmt>0</BorrowerAmt><OtherAmt>0</OtherAmt><PPFC>False</PPFC><FlatFee>False</FlatFee><PaidBy>B</PaidBy><AmtFinFlg>False</AmtFinFlg><ReqAmtFlg>True</ReqAmtFlg></FinancedFee><FinancedFee Type="54"><Amount>0</Amount><FeesDesc>Doc Fee</FeesDesc><FinPoc>Y</FinPoc><Include>True</Include><LenderAmt>0</LenderAmt><BorrowerAmt>0</BorrowerAmt><OtherAmt>0</OtherAmt><PPFC>False</PPFC><FlatFee>False</FlatFee><PaidBy>B</PaidBy><AmtFinFlg>False</AmtFinFlg><ReqAmtFlg>True</ReqAmtFlg></FinancedFee><FinancedFee Type="55"><Amount>0</Amount><FeesDesc>Title Fee</FeesDesc><FinPoc>Y</FinPoc><Include>True</Include><LenderAmt>0</LenderAmt><BorrowerAmt>0</BorrowerAmt><OtherAmt>0</OtherAmt><PPFC>False</PPFC><FlatFee>False</FlatFee><PaidBy>B</PaidBy><AmtFinFlg>False</AmtFinFlg><ReqAmtFlg>True</ReqAmtFlg></FinancedFee><FinancedFee Type="84"><Amount>0</Amount><FeesDesc>Dealer Participation</FeesDesc><FinPoc>Y</FinPoc><Include>True</Include><LenderAmt>0</LenderAmt><BorrowerAmt>0</BorrowerAmt><OtherAmt>0</OtherAmt><PPFC>False</PPFC><FlatFee>False</FlatFee><PaidBy>O</PaidBy><AmtFinFlg>False</AmtFinFlg><ReqAmtFlg>True</ReqAmtFlg></FinancedFee><FinancedFee Type="99"><Amount>0</Amount><FeesDesc>Prior Loan Payoff</FeesDesc><FinPoc>Y</FinPoc><Include>True</Include><LenderAmt>0</LenderAmt><BorrowerAmt>0</BorrowerAmt><OtherAmt>0</OtherAmt><PPFC>False</PPFC><FlatFee>False</FlatFee><PaidBy>B</PaidBy><AmtFinFlg>False</AmtFinFlg><ReqAmtFlg>True</ReqAmtFlg></FinancedFee><FinancedFee Type="158"><Amount>0</Amount><FeesDesc>State Tax Stamp</FeesDesc><FinPoc>Y</FinPoc><Include>True</Include><LenderAmt>0</LenderAmt><BorrowerAmt>0</BorrowerAmt><OtherAmt>0</OtherAmt><PPFC>False</PPFC><FlatFee>False</FlatFee><PaidBy>B</PaidBy><AmtFinFlg>False</AmtFinFlg><ReqAmtFlg>True</ReqAmtFlg></FinancedFee><FinancedFeeSum><TotalLenderFee>0</TotalLenderFee><TotalBorrowerFee>0</TotalBorrowerFee><TotalOtherFee>0</TotalOtherFee><TotalFinancedFee>0</TotalFinancedFee><TotalNonFinancedFee>0</TotalNonFinancedFee><TotalPPFCFee>0</TotalPPFCFee><TotalNonPPFCFee>0</TotalNonPPFCFee><TotalPOCFee>0</TotalPOCFee><TotalFee>0</TotalFee><TotalIncAmtFee>0</TotalIncAmtFee><TotalDealerFee>0</TotalDealerFee><LessNonFinPPFC>0</LessNonFinPPFC></FinancedFeeSum></FinancedFees></Finance><ContractFinance><FinancedFees><FinancedFee Type="35"><Amount>0</Amount><FeesDesc>GAP Fee</FeesDesc><FinPoc>Y</FinPoc><Include>True</Include><LenderAmt>0</LenderAmt><BorrowerAmt>0</BorrowerAmt><OtherAmt>0</OtherAmt><PPFC>False</PPFC><FlatFee>False</FlatFee><PaidBy>B</PaidBy><AmtFinFlg>False</AmtFinFlg><ReqAmtFlg>True</ReqAmtFlg></FinancedFee><FinancedFee Type="36"><Amount>0</Amount><FeesDesc>Misc</FeesDesc><FinPoc>Y</FinPoc><Include>True</Include><LenderAmt>0</LenderAmt><BorrowerAmt>0</BorrowerAmt><OtherAmt>0</OtherAmt><PPFC>False</PPFC><FlatFee>False</FlatFee><PaidBy>B</PaidBy><AmtFinFlg>False</AmtFinFlg><ReqAmtFlg>True</ReqAmtFlg></FinancedFee><FinancedFee Type="53"><Amount>0</Amount><FeesDesc>Service Contract</FeesDesc><FinPoc>Y</FinPoc><Include>True</Include><LenderAmt>0</LenderAmt><BorrowerAmt>0</BorrowerAmt><OtherAmt>0</OtherAmt><PPFC>False</PPFC><FlatFee>False</FlatFee><PaidBy>B</PaidBy><AmtFinFlg>False</AmtFinFlg><ReqAmtFlg>True</ReqAmtFlg></FinancedFee><FinancedFee Type="54"><Amount>0</Amount><FeesDesc>Doc Fee</FeesDesc><FinPoc>Y</FinPoc><Include>True</Include><LenderAmt>0</LenderAmt><BorrowerAmt>0</BorrowerAmt><OtherAmt>0</OtherAmt><PPFC>False</PPFC><FlatFee>False</FlatFee><PaidBy>B</PaidBy><AmtFinFlg>False</AmtFinFlg><ReqAmtFlg>True</ReqAmtFlg></FinancedFee><FinancedFee Type="55"><Amount>0</Amount><FeesDesc>Title Fee</FeesDesc><FinPoc>Y</FinPoc><Include>True</Include><LenderAmt>0</LenderAmt><BorrowerAmt>0</BorrowerAmt><OtherAmt>0</OtherAmt><PPFC>False</PPFC><FlatFee>False</FlatFee><PaidBy>B</PaidBy><AmtFinFlg>False</AmtFinFlg><ReqAmtFlg>True</ReqAmtFlg></FinancedFee><FinancedFee Type="84"><Amount>0</Amount><FeesDesc>Dealer Participation</FeesDesc><FinPoc>Y</FinPoc><Include>True</Include><LenderAmt>0</LenderAmt><BorrowerAmt>0</BorrowerAmt><OtherAmt>0</OtherAmt><PPFC>False</PPFC><FlatFee>False</FlatFee><PaidBy>O</PaidBy><AmtFinFlg>False</AmtFinFlg><ReqAmtFlg>True</ReqAmtFlg></FinancedFee><FinancedFee Type="99"><Amount>0</Amount><FeesDesc>Prior Loan Payoff</FeesDesc><FinPoc>Y</FinPoc><Include>True</Include><LenderAmt>0</LenderAmt><BorrowerAmt>0</BorrowerAmt><OtherAmt>0</OtherAmt><PPFC>False</PPFC><FlatFee>False</FlatFee><PaidBy>B</PaidBy><AmtFinFlg>False</AmtFinFlg><ReqAmtFlg>True</ReqAmtFlg></FinancedFee><FinancedFee Type="158"><Amount>0</Amount><FeesDesc>State Tax Stamp</FeesDesc><FinPoc>Y</FinPoc><Include>True</Include><LenderAmt>0</LenderAmt><BorrowerAmt>0</BorrowerAmt><OtherAmt>0</OtherAmt><PPFC>False</PPFC><FlatFee>False</FlatFee><PaidBy>B</PaidBy><AmtFinFlg>False</AmtFinFlg><ReqAmtFlg>True</ReqAmtFlg></FinancedFee><FinancedFeeSum><TotalLenderFee>0</TotalLenderFee><TotalBorrowerFee>0</TotalBorrowerFee><TotalOtherFee>0</TotalOtherFee><TotalFinancedFee>0</TotalFinancedFee><TotalNonFinancedFee>0</TotalNonFinancedFee><TotalPPFCFee>0</TotalPPFCFee><TotalNonPPFCFee>0</TotalNonPPFCFee><TotalPOCFee>0</TotalPOCFee><TotalFee>0</TotalFee><TotalIncAmtFee>0</TotalIncAmtFee><TotalDealerFee>0</TotalDealerFee><LessNonFinPPFC>0</LessNonFinPPFC></FinancedFeeSum></FinancedFees><Disclosure><Rate>11.3</Rate><Term>72</Term><AmountFinanced>15200</AmountFinanced><FinanceCharge>5898.16</FinanceCharge><TotalOfPayments>21098.16</TotalOfPayments><TotalDownPayment>0</TotalDownPayment><TotalSalesPrice>21098.16</TotalSalesPrice><RepaymentMethod>Installment</RepaymentMethod><IndexType>0</IndexType><IndexRate>0</IndexRate><Margin>0</Margin></Disclosure><Itemizations><SalesTax>0</SalesTax><CashPrice>0</CashPrice><NetTradeIn>0</NetTradeIn><TotalDown>0</TotalDown><DealerIncentive>0</DealerIncentive><OtherAmount>0</OtherAmount><DiscountAmount>0</DiscountAmount><DeferredDownPayment>0</DeferredDownPayment><ADandD>0</ADandD><OtherPublicFee>0</OtherPublicFee><OtherInsuranceFee>0</OtherInsuranceFee><Proceeds>0</Proceeds><ProceedsAdjustment>0</ProceedsAdjustment><TotalFundingProceeds>0</TotalFundingProceeds></Itemizations><ContractAmount>15200</ContractAmount><RepaymentMethod>Installment</RepaymentMethod><FirstPaymentDate><Date><Year>2014</Year><Month>06</Month><Day>02</Day></Date></FirstPaymentDate><LineOfCredit>15200</LineOfCredit><ItemizationsLenderGap>0</ItemizationsLenderGap><PrepaymentPenalty /><OverdraftProtection /><AutoPayFlag /></ContractFinance><Applicant><Personal><Individuals><Individual Duplicate="" Entity="A1" Fraud="False" Type="Applicant"><AnalystApproved><Rate>11.3</Rate><Term>72</Term><Amount>15200</Amount><Payment>293.03</Payment><AnalystName>Tereance Dennis</AnalystName><AnalystGrade>F1</AnalystGrade><PreApproveFlg>0</PreApproveFlg><AnalystUserID>TDENNIS</AnalystUserID><BureauScore>678</BureauScore></AnalystApproved><LatestDecision><BureauScore>678</BureauScore><OfficerNumber>C</OfficerNumber></LatestDecision><GivenName><FirstName>BRODERICK</FirstName><LastName>TOWNS</LastName></GivenName><SSN>418926601</SSN><DateOfBirth><Date><Year>1958</Year><Month>10</Month><Day>21</Day></Date></DateOfBirth><Military /><RemoteRefNumber>1351848</RemoteRefNumber><Credit><AddedDebt>600</AddedDebt></Credit><ContactInfo><Phone><AreaCode>256</AreaCode><Exchange>329</Exchange><LastPart>8639</LastPart></Phone><Mobile><AreaCode>000</AreaCode><Exchange>000</Exchange><LastPart>0000</LastPart></Mobile><Address Type="Current"><StreetName>15th Place</StreetName><City>ALEXANDER CITY</City><State>AL</State><Zip>35010</Zip><TimeAtLocation><Year>12</Year><Month>0</Month></TimeAtLocation><StreetNumber>2052</StreetNumber></Address></ContactInfo><Age>55</Age><OptOut /><AutoDecExpt /><CurCustomer /><Signer>True</Signer><Rego>False</Rego><TotalAdjustedIncomeNum>2100</TotalAdjustedIncomeNum><Resident Type="Homeowner"><Payment>500</Payment></Resident><Employment CurrentEmployer="True" Status="Other"><Employer><EmployerName>Social Security</EmployerName><ContactInfo><Phone><AreaCode>000</AreaCode><Exchange>000</Exchange><LastPart>0000</LastPart></Phone></ContactInfo></Employer><Years>0</Years><Months>6</Months><Income Basis="Monthly" Gross="True">1600</Income><GrossMonthlyIncome>1600</GrossMonthlyIncome><SecondCurrentEmployerFlg>False</SecondCurrentEmployerFlg></Employment><Employment CurrentEmployer="False" Status="Other"><Employer><EmployerName>Frontier Yards</EmployerName><ContactInfo><Phone><AreaCode>000</AreaCode><Exchange>000</Exchange><LastPart>0000</LastPart></Phone></ContactInfo></Employer><Years>7</Years><Months>0</Months><Income Gross="" /><SecondCurrentEmployerFlg>False</SecondCurrentEmployerFlg></Employment><Employment CurrentEmployer="True"><Income Basis="Annual" Gross="True">0</Income><GrossMonthlyIncome>0</GrossMonthlyIncome><SecondCurrentEmployerFlg>True</SecondCurrentEmployerFlg></Employment><OtherIncomes><OtherIncome Basis="Monthly" Gross="True"><Source>0.00</Source><Income>500</Income><MonthlyIncome>0</MonthlyIncome></OtherIncome><OtherIncome Basis="Monthly" Gross="True"><Source>Unknown</Source><Income>0</Income></OtherIncome></OtherIncomes><BureauScores><BureauScore><Bureau>XPN</Bureau><ScoreNum>678</ScoreNum><ScoreModel>V</ScoreModel></BureauScore><BureauScore><Bureau>XPN</Bureau><ScoreNum>650</ScoreNum><ScoreModel>AG</ScoreModel></BureauScore></BureauScores><ScoreCards><ApplicationScoreCard><Score>482</Score><ScoreGrade>F1</ScoreGrade></ApplicationScoreCard></ScoreCards></Individual></Individuals></Personal></Applicant><ContractRequest><Documents /></ContractRequest><ContractCollateral Type="Auto" /><ContractSchedules><Schedule><Order>1</Order><NumberOfPayments>72</NumberOfPayments><PaymentAmount>293.03</PaymentAmount><FirstPaymentDue><Date><Year>2014</Year><Month>06</Month><Day>02</Day></Date></FirstPaymentDue><Frequency>Monthly</Frequency></Schedule></ContractSchedules><Originator OID="93945"><Contact>TODD</Contact><Phone><AreaCode>800</AreaCode><Exchange>900</Exchange><LastPart>5150</LastPart></Phone><Priority>True</Priority><OriginatorCode>40511</OriginatorCode><ACH_DFI_ID>11100002</ACH_DFI_ID><Prenotification>1</Prenotification><BuyingCenter>Western</BuyingCenter><PreApproved /><Territory>Direct Lending</Territory><DealerType>Direct - Partner</DealerType><DealerName>USAA - PHONE</DealerName><SalesRepresentative>400001</SalesRepresentative><FundingMethod>Company Check</FundingMethod><AffiliateID>40511</AffiliateID><SalesRepFirstName>Direct</SalesRepFirstName><SalesRepLastName>Lending</SalesRepLastName><BuyingCenterID>1</BuyingCenterID><Eval_Prenotification>0</Eval_Prenotification><Evaluator_Name>CarFinance Capital</Evaluator_Name><Addresses><Address Type="Current"><AddressLine1>7525 irvine center dr</AddressLine1><City>irvine</City><State>CA</State><Zip>92618</Zip></Address><Address Type="Billing"><AddressLine1>7525 irvine center dr</AddressLine1><City>irvine</City><State>CA</State><Zip>92618</Zip></Address><Address Type="Funding"><AddressLine1>7525 irvine center dr</AddressLine1><City>irvine</City><State>CA</State><Zip>92618</Zip></Address><CommunicationType Type="Fax" /><CommunicationType Type="Fax" /><CommunicationType Type="Fax" /><CommunicationType Type="Fax" /><CommunicationType Type="Fax" /><CommunicationType Type="Fax" /></Addresses><MiscItems><MiscItem ID="1" /><MiscItem ID="2" /><MiscItem ID="3" /><MiscItem ID="4" /><MiscItem ID="5" /></MiscItems></Originator></LoanAppRq></LoanAppSvcRq></CreditSvcRq></IFX>';
      Dom.Document xmlDoc = new Dom.Document();
         xmlDoc.load(xmlStr);
         IFXLoadXML.IFXLoanAppRq ifxObj = new IFXLoadXML.IFXLoanAppRq(xmlDoc.getRootElement());
         System.assertNotEquals(null, xmlDoc);
What must be done to test that both the xmlDoc is not null and that the XMLNodes are not null either?

kaustav goswamikaustav goswami
Hi,

If you want to validate whether the child elements are null or not you will have to use the XmlNode class.

This class contains methods like getChildElement or getChildElements or getChildren.

For a complete reference to this class please refer to this link -

http://www.salesforce.com/us/developer/docs/dbcom_apex250/Content/apex_classes_xml_dom_xmlnode.htm

Please let us know if this helps.

Thanks,
Kaustav
Sid ChildersSid Childers
Thanks Kaustav.  Turns out there were 2 XML files that needed to be tested.  I'm now at 60% coverage.  Liens that are not covered have to do with the XML child element.  Please see the following sample:
global class DCOwnerInformation {
        global string UserName;
        global DCOwnerInformation(Dom.XmlNode node) {
            Dom.XmlNode child = node.getChildElement('UserName', null);
            if (child != null) {
                UserName = child.getText();
            }            
        }
    }

The if clause line is not currently covered by a test.  As per previous, I'm simply checking to see if there's an XML document.  Can you suggest how I might be able to test around the if clause in the above sample?

kaustav goswamikaustav goswami
If I understand the issue correctly then you have an paex class that accepts a xml and parses it. Now you want to write the test class that will cover this apex class.

In the code snippet above the constructor accepts a XmlNode and then you are trying to get a child of that node called UserName. The problem is the node that is being passed do not have a direct child named UserName. Thus it is returning null.

I think the other way of getting the children can be the use of the getChildren() method or the getChildElements() method. This will return all the children of a passed XmlNode. Now you can recursively call and traverse through the nodes by using a while loop. It will be really helpful if you can post two things.

The apex class for which you are trying to write the test class.
The sample XML document which gets parsed by the apex class.

Thanks,
Kaustav
Sid ChildersSid Childers
Hi Kaustav,

The Apex class I'm trying to test is the class already posted above.  The OwnerInformation node is pasted below:
<Owners>
    <OwnerInformation>
      <Email>me@me.com</Email>
      <FirstName>InternalFirstName</FirstName>
      <Id>12345</Id>
      <IsInternal>false</IsInternal>
      <LastName>InternalLastName</LastName>
      <Phone>800-999-9999</Phone>
      <RoleName>Agent</RoleName>
    </OwnerInformation>
  </Owners>

There isn't a user name that's part of this node.  Is that why the test is not covering the above class?
kaustav goswamikaustav goswami
Yes if the node that you are searching is not present then get child element will always return null