System.XmlException: start tag unexpected character =





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







2















This is the full error:



System.XmlException: start tag unexpected character = (position: END_TAG seen ...<source> Bicycling</source><media:contenturl=... @1:688)


So from my understanding, this is not valid XML. I was having an issue with the session body and had to make the following change:



<rss xmlns:media="http:..." and had to add <rsstxlmns:media="https:..."


Now, I am not sure how to go about this with the = sign.



@isTest
global class getRSSFeedMockCallout implements HttpCalloutMock
{

global HttpResponse respond(HttpRequest request)
{
String sessionBody = '<rsstxmlns:media="http://search.yahoo.com/mrss/"version="2.0">' +
'<channel>'+
'<item>'+
'<title>Draymond Green Is a SoulCycle Devotee - Bicycling</title>'+
'<link>https://www.bicycling.com/news/a27024393/draymond-green-soulcycle/</link>'+
'<pubDate>Wed, 03 Apr 2019 12:00:00 GMT</pubDate>'+
'<description><a href="https://www.bicycling.com/news/a27024393/draymond-green-soulcycle/"target="_blank">Draymond Green Is a SoulCycle Devotee</a>&nbsp;&nbsp;<font color="#6f6f6f">Bicycling</font><p>If you take SoulCycle classes in the Bay Area, and you notice one extremely tall guy in the room, you may be looking at Golden State Warriors star Draymond ...</p></description>'+
'<source>Bicycling</source>'+
'<media:contenturl="https://lh5.googleusercontent.com/proxy/QvLCgDJMIqLENGFBUt1CCoUPO1XB6gJkGFPV5FuM0QKfyaG8WdhuHGtfcVaTzNzPAYyHo-arnqUBkWkZ8s7-p7WBUbKlfJ4xr0hl8hltQWsBCG0yDDh13Ul5qKrZgLvjQitRecmu=-w150-h150-c"medium="image"width="150"height="150"/>'+
'</item>'+
'</channel>'+
'</rss>';


HttpResponse res = new HttpResponse();
res.setHeader('Content-Type', 'text/xml');
res.setBody( sessionBody );
res.setStatusCode(200);
return res;
}
}









share|improve this question









New contributor




Matthew Metros is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



























    2















    This is the full error:



    System.XmlException: start tag unexpected character = (position: END_TAG seen ...<source> Bicycling</source><media:contenturl=... @1:688)


    So from my understanding, this is not valid XML. I was having an issue with the session body and had to make the following change:



    <rss xmlns:media="http:..." and had to add <rsstxlmns:media="https:..."


    Now, I am not sure how to go about this with the = sign.



    @isTest
    global class getRSSFeedMockCallout implements HttpCalloutMock
    {

    global HttpResponse respond(HttpRequest request)
    {
    String sessionBody = '<rsstxmlns:media="http://search.yahoo.com/mrss/"version="2.0">' +
    '<channel>'+
    '<item>'+
    '<title>Draymond Green Is a SoulCycle Devotee - Bicycling</title>'+
    '<link>https://www.bicycling.com/news/a27024393/draymond-green-soulcycle/</link>'+
    '<pubDate>Wed, 03 Apr 2019 12:00:00 GMT</pubDate>'+
    '<description><a href="https://www.bicycling.com/news/a27024393/draymond-green-soulcycle/"target="_blank">Draymond Green Is a SoulCycle Devotee</a>&nbsp;&nbsp;<font color="#6f6f6f">Bicycling</font><p>If you take SoulCycle classes in the Bay Area, and you notice one extremely tall guy in the room, you may be looking at Golden State Warriors star Draymond ...</p></description>'+
    '<source>Bicycling</source>'+
    '<media:contenturl="https://lh5.googleusercontent.com/proxy/QvLCgDJMIqLENGFBUt1CCoUPO1XB6gJkGFPV5FuM0QKfyaG8WdhuHGtfcVaTzNzPAYyHo-arnqUBkWkZ8s7-p7WBUbKlfJ4xr0hl8hltQWsBCG0yDDh13Ul5qKrZgLvjQitRecmu=-w150-h150-c"medium="image"width="150"height="150"/>'+
    '</item>'+
    '</channel>'+
    '</rss>';


    HttpResponse res = new HttpResponse();
    res.setHeader('Content-Type', 'text/xml');
    res.setBody( sessionBody );
    res.setStatusCode(200);
    return res;
    }
    }









    share|improve this question









    New contributor




    Matthew Metros is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      2












      2








      2


      1






      This is the full error:



      System.XmlException: start tag unexpected character = (position: END_TAG seen ...<source> Bicycling</source><media:contenturl=... @1:688)


      So from my understanding, this is not valid XML. I was having an issue with the session body and had to make the following change:



      <rss xmlns:media="http:..." and had to add <rsstxlmns:media="https:..."


      Now, I am not sure how to go about this with the = sign.



      @isTest
      global class getRSSFeedMockCallout implements HttpCalloutMock
      {

      global HttpResponse respond(HttpRequest request)
      {
      String sessionBody = '<rsstxmlns:media="http://search.yahoo.com/mrss/"version="2.0">' +
      '<channel>'+
      '<item>'+
      '<title>Draymond Green Is a SoulCycle Devotee - Bicycling</title>'+
      '<link>https://www.bicycling.com/news/a27024393/draymond-green-soulcycle/</link>'+
      '<pubDate>Wed, 03 Apr 2019 12:00:00 GMT</pubDate>'+
      '<description><a href="https://www.bicycling.com/news/a27024393/draymond-green-soulcycle/"target="_blank">Draymond Green Is a SoulCycle Devotee</a>&nbsp;&nbsp;<font color="#6f6f6f">Bicycling</font><p>If you take SoulCycle classes in the Bay Area, and you notice one extremely tall guy in the room, you may be looking at Golden State Warriors star Draymond ...</p></description>'+
      '<source>Bicycling</source>'+
      '<media:contenturl="https://lh5.googleusercontent.com/proxy/QvLCgDJMIqLENGFBUt1CCoUPO1XB6gJkGFPV5FuM0QKfyaG8WdhuHGtfcVaTzNzPAYyHo-arnqUBkWkZ8s7-p7WBUbKlfJ4xr0hl8hltQWsBCG0yDDh13Ul5qKrZgLvjQitRecmu=-w150-h150-c"medium="image"width="150"height="150"/>'+
      '</item>'+
      '</channel>'+
      '</rss>';


      HttpResponse res = new HttpResponse();
      res.setHeader('Content-Type', 'text/xml');
      res.setBody( sessionBody );
      res.setStatusCode(200);
      return res;
      }
      }









      share|improve this question









      New contributor




      Matthew Metros is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      This is the full error:



      System.XmlException: start tag unexpected character = (position: END_TAG seen ...<source> Bicycling</source><media:contenturl=... @1:688)


      So from my understanding, this is not valid XML. I was having an issue with the session body and had to make the following change:



      <rss xmlns:media="http:..." and had to add <rsstxlmns:media="https:..."


      Now, I am not sure how to go about this with the = sign.



      @isTest
      global class getRSSFeedMockCallout implements HttpCalloutMock
      {

      global HttpResponse respond(HttpRequest request)
      {
      String sessionBody = '<rsstxmlns:media="http://search.yahoo.com/mrss/"version="2.0">' +
      '<channel>'+
      '<item>'+
      '<title>Draymond Green Is a SoulCycle Devotee - Bicycling</title>'+
      '<link>https://www.bicycling.com/news/a27024393/draymond-green-soulcycle/</link>'+
      '<pubDate>Wed, 03 Apr 2019 12:00:00 GMT</pubDate>'+
      '<description><a href="https://www.bicycling.com/news/a27024393/draymond-green-soulcycle/"target="_blank">Draymond Green Is a SoulCycle Devotee</a>&nbsp;&nbsp;<font color="#6f6f6f">Bicycling</font><p>If you take SoulCycle classes in the Bay Area, and you notice one extremely tall guy in the room, you may be looking at Golden State Warriors star Draymond ...</p></description>'+
      '<source>Bicycling</source>'+
      '<media:contenturl="https://lh5.googleusercontent.com/proxy/QvLCgDJMIqLENGFBUt1CCoUPO1XB6gJkGFPV5FuM0QKfyaG8WdhuHGtfcVaTzNzPAYyHo-arnqUBkWkZ8s7-p7WBUbKlfJ4xr0hl8hltQWsBCG0yDDh13Ul5qKrZgLvjQitRecmu=-w150-h150-c"medium="image"width="150"height="150"/>'+
      '</item>'+
      '</channel>'+
      '</rss>';


      HttpResponse res = new HttpResponse();
      res.setHeader('Content-Type', 'text/xml');
      res.setBody( sessionBody );
      res.setStatusCode(200);
      return res;
      }
      }






      apex xml httpcalloutmock xmlparsing






      share|improve this question









      New contributor




      Matthew Metros is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Matthew Metros is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited yesterday









      Dave Humm

      4,57951431




      4,57951431






      New contributor




      Matthew Metros is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked yesterday









      Matthew MetrosMatthew Metros

      111




      111




      New contributor




      Matthew Metros is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Matthew Metros is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Matthew Metros is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          1 Answer
          1






          active

          oldest

          votes


















          4














          There are few things wrong with the xml.



          1) In Apex, the string starts and end with single quotes ' , thus you don't need to escape "



          2) You cannot use & in XML, it makes XML invalid, you have to escape it. &nbsp; will become &amp;nbsp;



          3) There is no tag as media:contenturl in rss specification ,the tag is media:content and having url as an attribute. Seems like you missed a space in that.



          Thus fixing all the above problem and formating the code, the code would be something like



          String input = '<rss xmlns:media="http://search.yahoo.com/mrss/" version="2.0">' +
          '<channel>' +
          '<item>' +
          '<title>Draymond Green Is a SoulCycle Devotee - Bicycling</title>' +
          '<link>https://www.bicycling.com/news/a27024393/draymond-green-soulcycle/</link>' +
          '<pubDate>Wed, 03 Apr 2019 12:00:00 GMT</pubDate>' +
          '<description>' +
          '<a href="https://www.bicycling.com/news/a27024393/draymond-green-soulcycle/" target="_blank">Draymond Green Is a SoulCycle Devotee &amp;nbsp;&amp;nbsp; </a>' +
          '<font color="#6f6f6f">Bicycling</font>' +
          '<p>If you take SoulCycle classes in the Bay Area, and you notice one extremely tall guy in the room, you may be looking at Golden State Warriors star Draymond ...</p>' +
          '</description>' +
          '<source>Bicycling</source>' +
          '<media:content url ="https://lh5.googleusercontent.com/proxy/QvLCgDJMIqLENGFBUt1CCoUPO1XB6gJkGFPV5FuM0QKfyaG8WdhuHGtfcVaTzNzPAYyHo-arnqUBkWkZ8s7-p7WBUbKlfJ4xr0hl8hltQWsBCG0yDDh13Ul5qKrZgLvjQitRecmu=-w150-h150-c" medium="image" width="150" height="150"/>' +
          '</item>' +
          '</channel>' +
          '</rss>';


          System.debug(input);





          share|improve this answer
























          • You are the man! Works perfectly now.

            – Matthew Metros
            yesterday












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "459"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Matthew Metros is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f256980%2fsystem-xmlexception-start-tag-unexpected-character%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          There are few things wrong with the xml.



          1) In Apex, the string starts and end with single quotes ' , thus you don't need to escape "



          2) You cannot use & in XML, it makes XML invalid, you have to escape it. &nbsp; will become &amp;nbsp;



          3) There is no tag as media:contenturl in rss specification ,the tag is media:content and having url as an attribute. Seems like you missed a space in that.



          Thus fixing all the above problem and formating the code, the code would be something like



          String input = '<rss xmlns:media="http://search.yahoo.com/mrss/" version="2.0">' +
          '<channel>' +
          '<item>' +
          '<title>Draymond Green Is a SoulCycle Devotee - Bicycling</title>' +
          '<link>https://www.bicycling.com/news/a27024393/draymond-green-soulcycle/</link>' +
          '<pubDate>Wed, 03 Apr 2019 12:00:00 GMT</pubDate>' +
          '<description>' +
          '<a href="https://www.bicycling.com/news/a27024393/draymond-green-soulcycle/" target="_blank">Draymond Green Is a SoulCycle Devotee &amp;nbsp;&amp;nbsp; </a>' +
          '<font color="#6f6f6f">Bicycling</font>' +
          '<p>If you take SoulCycle classes in the Bay Area, and you notice one extremely tall guy in the room, you may be looking at Golden State Warriors star Draymond ...</p>' +
          '</description>' +
          '<source>Bicycling</source>' +
          '<media:content url ="https://lh5.googleusercontent.com/proxy/QvLCgDJMIqLENGFBUt1CCoUPO1XB6gJkGFPV5FuM0QKfyaG8WdhuHGtfcVaTzNzPAYyHo-arnqUBkWkZ8s7-p7WBUbKlfJ4xr0hl8hltQWsBCG0yDDh13Ul5qKrZgLvjQitRecmu=-w150-h150-c" medium="image" width="150" height="150"/>' +
          '</item>' +
          '</channel>' +
          '</rss>';


          System.debug(input);





          share|improve this answer
























          • You are the man! Works perfectly now.

            – Matthew Metros
            yesterday
















          4














          There are few things wrong with the xml.



          1) In Apex, the string starts and end with single quotes ' , thus you don't need to escape "



          2) You cannot use & in XML, it makes XML invalid, you have to escape it. &nbsp; will become &amp;nbsp;



          3) There is no tag as media:contenturl in rss specification ,the tag is media:content and having url as an attribute. Seems like you missed a space in that.



          Thus fixing all the above problem and formating the code, the code would be something like



          String input = '<rss xmlns:media="http://search.yahoo.com/mrss/" version="2.0">' +
          '<channel>' +
          '<item>' +
          '<title>Draymond Green Is a SoulCycle Devotee - Bicycling</title>' +
          '<link>https://www.bicycling.com/news/a27024393/draymond-green-soulcycle/</link>' +
          '<pubDate>Wed, 03 Apr 2019 12:00:00 GMT</pubDate>' +
          '<description>' +
          '<a href="https://www.bicycling.com/news/a27024393/draymond-green-soulcycle/" target="_blank">Draymond Green Is a SoulCycle Devotee &amp;nbsp;&amp;nbsp; </a>' +
          '<font color="#6f6f6f">Bicycling</font>' +
          '<p>If you take SoulCycle classes in the Bay Area, and you notice one extremely tall guy in the room, you may be looking at Golden State Warriors star Draymond ...</p>' +
          '</description>' +
          '<source>Bicycling</source>' +
          '<media:content url ="https://lh5.googleusercontent.com/proxy/QvLCgDJMIqLENGFBUt1CCoUPO1XB6gJkGFPV5FuM0QKfyaG8WdhuHGtfcVaTzNzPAYyHo-arnqUBkWkZ8s7-p7WBUbKlfJ4xr0hl8hltQWsBCG0yDDh13Ul5qKrZgLvjQitRecmu=-w150-h150-c" medium="image" width="150" height="150"/>' +
          '</item>' +
          '</channel>' +
          '</rss>';


          System.debug(input);





          share|improve this answer
























          • You are the man! Works perfectly now.

            – Matthew Metros
            yesterday














          4












          4








          4







          There are few things wrong with the xml.



          1) In Apex, the string starts and end with single quotes ' , thus you don't need to escape "



          2) You cannot use & in XML, it makes XML invalid, you have to escape it. &nbsp; will become &amp;nbsp;



          3) There is no tag as media:contenturl in rss specification ,the tag is media:content and having url as an attribute. Seems like you missed a space in that.



          Thus fixing all the above problem and formating the code, the code would be something like



          String input = '<rss xmlns:media="http://search.yahoo.com/mrss/" version="2.0">' +
          '<channel>' +
          '<item>' +
          '<title>Draymond Green Is a SoulCycle Devotee - Bicycling</title>' +
          '<link>https://www.bicycling.com/news/a27024393/draymond-green-soulcycle/</link>' +
          '<pubDate>Wed, 03 Apr 2019 12:00:00 GMT</pubDate>' +
          '<description>' +
          '<a href="https://www.bicycling.com/news/a27024393/draymond-green-soulcycle/" target="_blank">Draymond Green Is a SoulCycle Devotee &amp;nbsp;&amp;nbsp; </a>' +
          '<font color="#6f6f6f">Bicycling</font>' +
          '<p>If you take SoulCycle classes in the Bay Area, and you notice one extremely tall guy in the room, you may be looking at Golden State Warriors star Draymond ...</p>' +
          '</description>' +
          '<source>Bicycling</source>' +
          '<media:content url ="https://lh5.googleusercontent.com/proxy/QvLCgDJMIqLENGFBUt1CCoUPO1XB6gJkGFPV5FuM0QKfyaG8WdhuHGtfcVaTzNzPAYyHo-arnqUBkWkZ8s7-p7WBUbKlfJ4xr0hl8hltQWsBCG0yDDh13Ul5qKrZgLvjQitRecmu=-w150-h150-c" medium="image" width="150" height="150"/>' +
          '</item>' +
          '</channel>' +
          '</rss>';


          System.debug(input);





          share|improve this answer













          There are few things wrong with the xml.



          1) In Apex, the string starts and end with single quotes ' , thus you don't need to escape "



          2) You cannot use & in XML, it makes XML invalid, you have to escape it. &nbsp; will become &amp;nbsp;



          3) There is no tag as media:contenturl in rss specification ,the tag is media:content and having url as an attribute. Seems like you missed a space in that.



          Thus fixing all the above problem and formating the code, the code would be something like



          String input = '<rss xmlns:media="http://search.yahoo.com/mrss/" version="2.0">' +
          '<channel>' +
          '<item>' +
          '<title>Draymond Green Is a SoulCycle Devotee - Bicycling</title>' +
          '<link>https://www.bicycling.com/news/a27024393/draymond-green-soulcycle/</link>' +
          '<pubDate>Wed, 03 Apr 2019 12:00:00 GMT</pubDate>' +
          '<description>' +
          '<a href="https://www.bicycling.com/news/a27024393/draymond-green-soulcycle/" target="_blank">Draymond Green Is a SoulCycle Devotee &amp;nbsp;&amp;nbsp; </a>' +
          '<font color="#6f6f6f">Bicycling</font>' +
          '<p>If you take SoulCycle classes in the Bay Area, and you notice one extremely tall guy in the room, you may be looking at Golden State Warriors star Draymond ...</p>' +
          '</description>' +
          '<source>Bicycling</source>' +
          '<media:content url ="https://lh5.googleusercontent.com/proxy/QvLCgDJMIqLENGFBUt1CCoUPO1XB6gJkGFPV5FuM0QKfyaG8WdhuHGtfcVaTzNzPAYyHo-arnqUBkWkZ8s7-p7WBUbKlfJ4xr0hl8hltQWsBCG0yDDh13Ul5qKrZgLvjQitRecmu=-w150-h150-c" medium="image" width="150" height="150"/>' +
          '</item>' +
          '</channel>' +
          '</rss>';


          System.debug(input);






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered yesterday









          Pranay JaiswalPranay Jaiswal

          18.7k53158




          18.7k53158













          • You are the man! Works perfectly now.

            – Matthew Metros
            yesterday



















          • You are the man! Works perfectly now.

            – Matthew Metros
            yesterday

















          You are the man! Works perfectly now.

          – Matthew Metros
          yesterday





          You are the man! Works perfectly now.

          – Matthew Metros
          yesterday










          Matthew Metros is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Matthew Metros is a new contributor. Be nice, and check out our Code of Conduct.













          Matthew Metros is a new contributor. Be nice, and check out our Code of Conduct.












          Matthew Metros is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Salesforce Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f256980%2fsystem-xmlexception-start-tag-unexpected-character%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to label and detect the document text images

          Vallis Paradisi

          Tabula Rosettana