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
anji punyamanthulaanji 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>
Aslam ChaudharyAslam Chaudhary
But your XML does not contains any SUB SUB child element.

I hope you are talking about attribute name , Age and Std. Let me know if you need to get that information.