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

Unable to get the values in Vf page

Hi all,

  My vf page and class is as below


<apex:page controller="XmlStreamDemo">
  <apex:form >
   <apex:commandButton value="Refer" action="{!refer}"/>  
   <apex:outputText value="{!socialnetwork}"></apex:outputText>   




public class XmlStreamDemo {
    public string link{get;set;}
    public String socialnetwork { get; set; }
   public class Network{
     String name;
     String Image;

   Network[] parseNetworks(XmlStreamReader reader) {
     Network[] socialnetwork = new Network[0];
     while(reader.hasNext()) {
         if (reader.getEventType() == XmlTag.START_ELEMENT) {
            if ('Network' == reader.getLocalName()) {

               Network link = parseNetwork(reader);
    return socialnetwork;
   Network parseNetwork(XmlStreamReader reader) {
     Network link = new Network();
     link.Image = reader.getAttributeValue(null, 'Image');
     while(reader.hasNext()) {
        if (reader.getEventType() == XmlTag.END_ELEMENT) {
        } else if (reader.getEventType() == XmlTag.CHARACTERS) {
  = reader.getText();
     return link;
  Public void refer() {

     XmlStreamDemo demo = new XmlStreamDemo();

     String str = '<socialnetwork><link Image="Chatty">Aruna</link>' +
        '<link Image="Sassy">Baz</link></socialnetwork>';
     XmlStreamReader reader2 = new XmlStreamReader(str);
     Network[] socialnetwork= demo.parseNetworks(reader2);

  // System.debug('==========='+socialnetwork);
     for (Network Image:socialnetwork1 ) {


 here the problem is Im unable to get the values in outputtext and whenever Im checking in debug it's showing the size as 0......Any reply would be greatly appreciated


Thanks in advance



Use rerender inside the apex:command button .


 Try the below code snippet as refenence:

<apex:page controller="XmlStreamDemo">

  <apex:form  id=”fo”>

   <apex:commandButton value="Refer" action="{!refer}" rerender=”fo”/> 

<apex:outputpanel id=”op”>


   <apex:outputText value="{!socialnetwork}"></apex:outputText> 

</apex:outputpane l>




Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 


Error: XmlStreamDemo Compile Error: The property String socialnetwork1 is referenced by Visualforce Page (xxx) in Remove the usage and try again. at line 3 column 19


getting this error.....dnt know why?