Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6241113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:42:01+00:00 2026-05-24T11:42:01+00:00

public with sharing class xml4 { public string x{get;set;} public string c{get;set;} List<ArtemisVC__Company_View_Extensions__c> mcs{get;

  • 0
public with sharing class xml4
{
public string x{get;set;}
public string c{get;set;}
List<ArtemisVC__Company_View_Extensions__c> mcs{get; set;}
public xml4 ()
{
    DOM.Document doc = new DOM.Document();
    dom.XmlNode Extensions = doc.createRootElement('Extensions',Null, Null);
    mcs=new List<ArtemisVC__Company_View_Extensions__c> ();
    mcs = ArtemisVC__Company_View_Extensions__c.getall().values();
    for(Integer i = 0 ; i <mcs.size(); i++)
    {
        dom.XmlNode Extension= Extensions.addChildElement('Extension',null , null);
        dom.XmlNode FieldName1= Extension.addChildElement('Name',null , null);
        FieldName1.addTextNode(mcs[i].Name);
        dom.XmlNode FieldName2=Extension.addChildElement('Url',null,null);
        //FieldName2.addTextNode(mcs[i].ArtemisVC__Extension_URL__c);        
        dom.XmlNode FieldName3=Extension.addChildElement('Expand-Collapse-SOQL',null,null);
        FieldName3.addTextNode(mcs[i].Expand_Collapse_SOQL__c); 
        dom.XmlNode FieldName4=Extension.addChildElement('Order',null,null);
       // FieldName4.addTextNode(mcs[i].ArtemisVC__Order__c); 
        dom.XmlNode FieldName5=Extension.addChildElement('Height',null,null);
        //FieldName5.addTextNode(mcs[i].Height__c); 
        dom.XmlNode FieldName6=Extension.addChildElement('Width',null,null);
      //  FieldName6.addTextNode(mcs[i].Width__c); 
        dom.XmlNode FieldName7=Extension.addChildElement('ForCompanyType',null,null);
     //   FieldName7.addTextNode(mcs[i].Show_For_CompanyType__c); 
 dom.XmlNode FieldName8=Extension.addChildElement('PageOrRelatedListName',null,null);
       // FieldName8.addTextNode(mcs[i].PageOrRelatedListName__c); 
    }
    x = doc.toXmlString();
    c = 'text/xml#sachin.xml';
}
}

In the above code i am getting exception as System.NullPointerException: Argument 1 cannot be null

Class.ArtemisVC.xml4.: line 20, column 43 External entry point

Line 20 is FieldName3.addTextNode(mcs[i].Expand_Collapse_SOQL__c);

Please tell me how to pass the dynamic value in addTextNode().

Dom.XmlNode addTextNode(String text) – Creates a child text node for this node. The text argument can’t have a null value.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:42:02+00:00Added an answer on May 24, 2026 at 11:42 am

    I’m assuming in this case that “mcs[i].ArtemisVC__Extension_URL__c” is null, so you can use the ternary to avoid passing that into the function like so:

        FieldName3.addTextNode(mcs[i].Expand_Collapse_SOQL__c != null ? mcs[i].Expand_Collapse_SOQL__c : '');
    

    If I’ve misunderstood, let me know!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a class public with sharing class CAccountRep { string sageAccountNo {get;set;} string
public class Address { public string ZipCode {get; set;} } public class Customer {
public static void main(String[] args) { List<? extends Object> mylist = new ArrayList<Object>(); mylist.add(Java);
public class Test { public static void main(String[] args) { } } class Outer
public class Item { ... } public class Order { public List<Item> Items ...
I'm sharing some variables accross activities by using a class like this : public
I have been sharing database variables using the following code: Namespace DataAccessVariables Public Class
I have the following code: public class boolq { public static void main(String[] args)
class B; class A { public: A () : m_b(new B()) { } shared_ptr<B>
Here are a few example of classes and properties sharing the same identifier: public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.