In the below code xml document is not getting loaded and throwing exception has been thrown by the target of an invocation.
classreadXML
{
publicstaticvoid main(Args _args)
{
XmlDocument doc= newXmlDocument();
XmlNodeList apiModelList;
XmlNodeListIterator iterator;
XmlElement apiModel;
XmlElement firstName;
XmlElement lastName;
//str s= @"C:\Users\Administrator\Desktop\Assessment.xml";
doc.load(@"C:\Users\Administrator\Desktop\Assessment.xml");
apiModelList = doc.getElementsByTagName('ItemGroup');
iterator= newXmlNodeListIterator(apiModelList);
while (iterator.moreValues())
{
apiModel = iterator.value();
firstName = apiModel.getNamedElement('Link');
if (firstName)
{
info(strFmt("First Name: %1", firstName.text()));
}
//lastName = apiModel.getNamedElement('LastName');
//if (lastName)
//{
// info(strFmt("Last Name: %1", lastName.text()));
//}
iterator.nextValue();
}
}
}