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
kito kidkito kid 

get the value of xml current event

If I want to get the value "https://www.test.com/1234" as below. How I can get it using XMLStreamReader.

 

<item>

....

<guid isPermaLink="false">https://www.test.com</guid>
<link>https://www.test.com/1234</link>

...

</item>

 

I am using the code below. how should I  get the value insides <link> tag.

I used getText(), but get errors.

 

if(reader.getEventType() == XmlTag.START_ELEMENT && reader.getLocalName() == 'link'){

//get link value

}

Best Answer chosen by Admin (Salesforce Developers) 
Bhawani SharmaBhawani Sharma
I would suggest to use DOM classes. XMLStreamReader is bit old and is out of fashion now.
It's very easy to use DOM classes :
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_xml_dom_document.htm

See the example, This is exactly what you are looking for.

All Answers

Bhawani SharmaBhawani Sharma
I would suggest to use DOM classes. XMLStreamReader is bit old and is out of fashion now.
It's very easy to use DOM classes :
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_xml_dom_document.htm

See the example, This is exactly what you are looking for.
This was selected as the best answer
kito kidkito kid
Thanks Bhawani, your quick reply is so encouraging for a newbie like me :D