Hi Folks,
I have following XML and looking for a way to read data for each node element under instructorApiModel
<ArrayOfInstructorApiModel xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.datacontract.org/.../07">
<InstructorApiModel>
<Address>TestAddress</Address>
<AxId></AxId>
<Email>tester@email.com</Email>
<FirstName>TestFirstName</FirstName>
<LastName>TestLastName</LastName>
<MiddleName>TestMiddleName</MiddleName>
<PhoneNumber>1234567890</PhoneNumber>
</InstructorApiModel>
<InstructorApiModel>
<Address>Ukraine</Address>
<AxId></AxId>
<Email>test@gmail.com</Email>
<FirstName>Rob</FirstName>
<LastName>yan</LastName>
<MiddleName i:nil="true" />
<PhoneNumber>1234567891</PhoneNumber>
</InstructorApiModel>
</ArrayOfInstructorApiModel>
I have following code in X++ but its not working - can anyone please suggest me what I am missing?
// Create the XML Document
doc = new XmlDocument();
doc.loadXml(_xmlMsg);
data = doc.selectNodes("//ArrayOfInstructorApiModel");
xmlNodeListIterator = new xmlNodeListIterator(data);
while(xmlNodeListIterator.moreValues())
{
node = xmlNodeListIterator.value();
if(node.selectSingleNode('FirstName'))
templateId = node.selectSingleNode('FirstName').text();
info(strFmt("First Name: %1", templateId));
if(node.selectSingleNode('LastName'))
templateName = node.selectSingleNode('LastName').text();
info(strFmt("First Name: %1", templateName));
xmlNodeListIterator.nextValue();
}
*This post is locked for comments
I have the same question (0)