You need to sign in to do that
Don't have an account?
anji punyamanthula
i'm trying parsneing the xml its giving child elements but not get geting child of children below is the code check any one and help me in that
public class XML_Example_4 {
public String result {set;get;}
public String parseText {set;get;}
public void parse(){
DOM.Document doc=new DOM.Document();
doc.load(parseText);
DOM.XMLNode root=doc.getRootElement();
result=root.getName();
List<DOM.XMLNode> childs= root.getChildElements();
for(DOM.XMLNode c:childs){
result=result+'\n'+c.getName()+' :'+c.getText();
if(c.getNamespace()=='Std'){
list<DOM.XMLNode> root1=c.getChildren();
for(DOM.XMLNode c1:root1){
result=result+c1.getName()+' :'+c1.getText();
}
}
System.debug('result1'+c.getChildren());
}
}
}
i'm passing this string
<?xml version="1.0" encoding="UTF-8"?><as:name xmlns:as="capital"><lastname>anji</lastname><Firstname>punyamanthula</Firstname><age>24</age><Student name="raju" Age="30" xmlns:std="capital" /></as:name>
public String result {set;get;}
public String parseText {set;get;}
public void parse(){
DOM.Document doc=new DOM.Document();
doc.load(parseText);
DOM.XMLNode root=doc.getRootElement();
result=root.getName();
List<DOM.XMLNode> childs= root.getChildElements();
for(DOM.XMLNode c:childs){
result=result+'\n'+c.getName()+' :'+c.getText();
if(c.getNamespace()=='Std'){
list<DOM.XMLNode> root1=c.getChildren();
for(DOM.XMLNode c1:root1){
result=result+c1.getName()+' :'+c1.getText();
}
}
System.debug('result1'+c.getChildren());
}
}
}
i'm passing this string
<?xml version="1.0" encoding="UTF-8"?><as:name xmlns:as="capital"><lastname>anji</lastname><Firstname>punyamanthula</Firstname><age>24</age><Student name="raju" Age="30" xmlns:std="capital" /></as:name>
I hope you are talking about attribute name , Age and Std. Let me know if you need to get that information.