You need to sign in to do that
Don't have an account?
DDay
Return type of XMLDom's getElementsByTagName('xxx') ?
Hello,
I'm using the XMLDom class to parse some XML. I'm trying to set a variable to a list of tag names that I can loop through later. What is the correct return type I should set 'names' in the following code to?
names = responseXML.getElementsByTagName('names');
I've tried setting it to List<String> but I get the following error:
Error: Compile Error: Illegal assignment from LIST:XMLDom.Element to LIST:String
Thanks,
Dan
Hi,
List<XMLDOM.Element> is the correct declaration.
J.
All Answers
getValue() method on the specific Element object in the List you are creating.
Hi Aish,
Thanks for the response. I'm coming from a PHP background so having to declare return types is throwing me for a loop. If I change that line to:
List<Element> names = responseXML.getElementsByTagName('names'); or public List<Element> names = new List<Element>();
I keep getting Compile Error: Invalid type: Element
The entire XMLDom class is in my apex classes section which has the Element class in it. This seems like such a basic thing but it's very frustrating.
Thanks,
Dan
Hi,
List<XMLDOM.Element> is the correct declaration.
J.
Thanks J, that did the trick!
Dan