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
king kpking kp 

Throwing this Error:"Unrecognized base64 character: ;"

used this code throwing this error: "Unrecognized base64 character: ;"  can any one please help me
for(Dom.XMLNode child : xrec) {

    //system.debug('child..'+child);
        for (dom.XmlNode awr : child.getchildren() ) {
        //System.debug('awr...'+awr);
            for(dom.XmlNode xy:awr.getchildren()){
            // system.debug('xy...'+xy);
                for(dom.XmlNode anc :xy.getchildren()){


                 //if(anc.gettext() != null ){
                 baseco=true;
                encodedvalue=anc.gettext();
                 Blob d = EncodingUtil.base64Decode(encodedvalue);
                        //system.debug('d...'+d);

                    decodedstring = d.tostring(); 
                }
                
            }
          
        }
       
    }

Thanks
kullayappa
Best Answer chosen by king kp
karthikeyan perumalkarthikeyan perumal
Hello 

dont use thsi. 

encodedvalue=encodedvalue.replace(';',' ');

use this below code:
for(Dom.XMLNode child : xrec) {

    //system.debug('child..'+child);
        for (dom.XmlNode awr : child.getchildren() ) {
        //System.debug('awr...'+awr);
            for(dom.XmlNode xy:awr.getchildren()){
            // system.debug('xy...'+xy);
                for(dom.XmlNode anc :xy.getchildren()){


                 //if(anc.gettext() != null ){
                 baseco=true;
                encodedvalue=anc.gettext();
                Blob d= Blob.valueof(encodedvalue);
                decodedstring =d.tostring();
                }
                
            }
          
        }
       
    }

howp this will work. if there is any error. let me know the error line exactly. also try to post the XML  

Thanks
karthik
 

All Answers

king kpking kp
Hi karthik,

i tried this code Throwing this error:"
Failed to parse XML due to: only whitespace content allowed before start tag and not P (position: START_DOCUMENT seen P... @1:1)"

Please help me

thanks
kullayappa
karthikeyan perumalkarthikeyan perumal
Hello 

can you post the value that you are getting in to this "anc.gettext()"  so that i can look in to this and let you know the correct one. 

Thanks
karthik
 
king kpking kp
HI karthik,

I am getting the data is:basecode64   anc.gettext(); in that code converting the XML format

These Xml code using the DOM.XML code this code using

Thanks
kullayappa
king kpking kp
Karthik,
 
i tried this code but throwing this error:

"Failed to parse XML due to: only whitespace content allowed before start tag and not P (position: START_DOCUMENT seen P... @1:1)"


for(Dom.XMLNode child : xrec) {

    //system.debug('child..'+child);
        for (dom.XmlNode awr : child.getchildren() ) {
        //System.debug('awr...'+awr);
            for(dom.XmlNode xy:awr.getchildren()){
            // system.debug('xy...'+xy);
                for(dom.XmlNode anc :xy.getchildren()){


                 //if(anc.gettext() != null ){
                 baseco=true;
                encodedvalue=anc.gettext();
                 
                    encodedvalue=encodedvalue.replace(';',' '); 
                    
                 
                    Blob d= Blob.valueof(encodedvalue);
                    decodedstring =d.tostring();

                }
                
            }
          
        }
       
    }

Thanks
kullayappa
king kpking kp
hi karthik,
Itried itially that code "*Blob d = EncodingUtil.base64Decode(encodedvalue);
                        //system.debug('d...'+d);
                    decodedstring = d.tostring();*/"


Throwing the same error.
Thanks
kullayappa
karthikeyan perumalkarthikeyan perumal
Hello 

dont use thsi. 

encodedvalue=encodedvalue.replace(';',' ');

use this below code:
for(Dom.XMLNode child : xrec) {

    //system.debug('child..'+child);
        for (dom.XmlNode awr : child.getchildren() ) {
        //System.debug('awr...'+awr);
            for(dom.XmlNode xy:awr.getchildren()){
            // system.debug('xy...'+xy);
                for(dom.XmlNode anc :xy.getchildren()){


                 //if(anc.gettext() != null ){
                 baseco=true;
                encodedvalue=anc.gettext();
                Blob d= Blob.valueof(encodedvalue);
                decodedstring =d.tostring();
                }
                
            }
          
        }
       
    }

howp this will work. if there is any error. let me know the error line exactly. also try to post the XML  

Thanks
karthik
 
This was selected as the best answer
king kpking kp
Hi karthik,

Throwing same error.

for(Dom.XMLNode child : xrec) {

    //system.debug('child..'+child);
        for (dom.XmlNode awr : child.getchildren() ) {
        //System.debug('awr...'+awr);
            for(dom.XmlNode xy:awr.getchildren()){
            // system.debug('xy...'+xy);
                for(dom.XmlNode anc :xy.getchildren()){


                 //if(anc.gettext() != null ){
                 baseco=true;
                encodedvalue=anc.gettext();
                 
                    //encodedvalue=encodedvalue.replace(';',' '); 
                    
                    /*Blob d = EncodingUtil.base64Decode(encodedvalue);
                        //system.debug('d...'+d);
                    decodedstring = d.tostring();*/
                    Blob d= Blob.valueof(encodedvalue);
                    decodedstring =d.tostring();
           

        Dom.Document docxxml = new Dom.Document();
          if(baseco==true)
            docxxml.load(decodedstring);
    dom.XmlNode xrootxml = docxxml.getrootelement() ;
            
    for(Dom.XMLNode child_rep: xrootxml.getChildElements()) {
        //  System.debug('head....'+child);
        for(Dom.XML

thanks
kullayappa