I am trying to parse a file from our meeting server with XML data. The data is structured like this:
<results>
<status code="ok"/>
<principal-list>
<principal principal-id="1089714827" account-id="1089571079" type="user" has-children="false" is-primary="false" is-hidden="false" training-group-id="">
<name>Research</name>
<login>[email protected]</login>
<email>[email protected]</email>
<display-uid>[email protected]</display-uid>
</principal>
...
</principal-list>
</results>
I am trying to get the text portion portion of the XML:
<name>Research</name>
<login>[email protected]</login>
<email>[email protected]</email>
<display-uid>[email protected]</display-uid>
I created a loop in my program that looks like this:
string enames;
string etext;
for (Dom.XMLNode child: row.getChildElements()){
for(Dom.XmlNode c: child.getChildElements()){
for(Dom.XmlNode d: c.getChildElements()){
if(d.getNodeType() == Dom.XmlNodeType.ELEMENT){
Enames += d.getName();}
else{
Etext = d.getText();}
}
}
}
All I get from that is the tag in etext.
Any suggestions would be great. Thanks in advanced.
This is the full request:
http h = new http();
httpRequest req = New httpRequest();
req.setEndpoint(logBase);
req.setMethod('GET');
req.setHeader('Cookie', 'BREEZESESSION=' + session);
httpResponse res = h.send(req);
System.debug(res.getBody());
Dom.Document docx = new Dom.Document();
docx.load(res.getBody());
dom.XmlNode row = docx.getRootElement();
string enames;
string etext;
for (Dom.XMLNode child: row.getChildElements()){
for(Dom.XmlNode c: child.getChildElements()){
for(Dom.XmlNode d: c.getChildElements()){
if(d.getNodeType() == Dom.XmlNodeType.ELEMENT){
Enames += d.getName();}
else{
Etext = d.getText();}
}
}
}