• sai Addagarla
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

The following Error I'm getting------------>
===============================
Argument cannot be null.
Error is in expression '{!callme}' in component <apex:commandButton> in page vf_xml_eg1_xmldynamicaccount: Class.Eg1_XML_Dserfromfile.callme: line 7, column 1
An unexpected error has occurred. Your development organization has been notified.

The following CLASS used------------>
===============================
public class Eg1_XML_Dserfromfile 
{
    public Blob xmlfile {set;get;}
    public void callme()
    {
        list<Account> accounts = new list<Account>();
        String xmlstring = xmlfile.tostring();
        xmlfile=null;
        DOM.Document doc=new Dom.Document();
        doc.load(xmlstring);
        DOM.XmlNode root = doc.getRootElement();
        list<DOM.XmlNode> branch =root.getchildElements();
        for(DOM.XmlNode eb:branch)
        {
            Account A = New Account();
            A.Name = eb.getAttributeValue('Name');
            A.Name = eb.getAttributeValue('Mobile');
            A.Name = eb.getAttributeValue('CompanyType');
            accounts.add(A);
            }
        insert accounts;
    }
}

The following COMPONENT used in the Visualforce------------>
==============================================
<apex:page controller="Eg1_XML_Dserfromfile" >
    <apex:form>
        <apex:inputFile value="{!xmlfile}" fileName="dummyfile">
        </apex:inputFile>
        <apex:commandButton value="Click here to import" action="{!callme}"/>
    </apex:form>
</apex:page>

 

---------------------
Please, help me out.

The following Error I'm getting------------>
===============================
Argument cannot be null.
Error is in expression '{!callme}' in component <apex:commandButton> in page vf_xml_eg1_xmldynamicaccount: Class.Eg1_XML_Dserfromfile.callme: line 7, column 1
An unexpected error has occurred. Your development organization has been notified.

The following CLASS used------------>
===============================
public class Eg1_XML_Dserfromfile 
{
    public Blob xmlfile {set;get;}
    public void callme()
    {
        list<Account> accounts = new list<Account>();
        String xmlstring = xmlfile.tostring();
        xmlfile=null;
        DOM.Document doc=new Dom.Document();
        doc.load(xmlstring);
        DOM.XmlNode root = doc.getRootElement();
        list<DOM.XmlNode> branch =root.getchildElements();
        for(DOM.XmlNode eb:branch)
        {
            Account A = New Account();
            A.Name = eb.getAttributeValue('Name');
            A.Name = eb.getAttributeValue('Mobile');
            A.Name = eb.getAttributeValue('CompanyType');
            accounts.add(A);
            }
        insert accounts;
    }
}

The following COMPONENT used in the Visualforce------------>
==============================================
<apex:page controller="Eg1_XML_Dserfromfile" >
    <apex:form>
        <apex:inputFile value="{!xmlfile}" fileName="dummyfile">
        </apex:inputFile>
        <apex:commandButton value="Click here to import" action="{!callme}"/>
    </apex:form>
</apex:page>

 

---------------------
Please, help me out.