0

I need to get all the values from child node

            <fields>
            <field1>Name</field1>
            <csv1>field1</csv1>
            </fields>

But i am not able to get then at a single loop i need to loop 2 times to get the values my code

 for(Dom.XMLNode subchild : child.getChildElements()) 
            {
                system.debug('Sub child ' + subchild.getText() );
                for(Dom.XMLNode subchildfield : subchild.getChildren())
                {
                    system.debug('Sub child Field ' + subchildfield.getText() );
                    fName  = subchildfield.getText();
                    fieldName.add(fName);
                    //fileValuesXML.add(fieldName);
                    //system.debug('Filed Name in XML field  ' + fieldName);
                }

                system.debug('Filed Name before affing to filevalueXML  ' + fieldName);                    
                fileValuesXML.add(fieldName);
                fieldName.clear();
                system.debug('Filed Name after affing to filevalueXML  ' + fileValuesXML);
            }

is it possible to get all the child node values at a single loop so that i can have it in a map. Please guide me

1 Answer 1

1

These links will help you:

Using APEX DOM parser: http://developer.force.com/cookbook/recipe/parsing-xml-using-the-apex-dom-parser

Using XMLStreamReader class

http://www.sundoginteractive.com/sunblog/posts/parsing-xml-in-salesforce-apex

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .