System.XmlException: start tag unexpected character =
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
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> <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
New contributor
add a comment |
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> <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
New contributor
add a comment |
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> <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
New contributor
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> <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
apex xml httpcalloutmock xmlparsing
New contributor
New contributor
edited 12 hours ago
Dave Humm
4,57951431
4,57951431
New contributor
asked 15 hours ago
Matthew MetrosMatthew Metros
111
111
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
will become &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 &nbsp;&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);
You are the man! Works perfectly now.
– Matthew Metros
14 hours ago
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
will become &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 &nbsp;&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);
You are the man! Works perfectly now.
– Matthew Metros
14 hours ago
add a comment |
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.
will become &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 &nbsp;&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);
You are the man! Works perfectly now.
– Matthew Metros
14 hours ago
add a comment |
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.
will become &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 &nbsp;&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);
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.
will become &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 &nbsp;&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);
answered 14 hours ago
Pranay JaiswalPranay Jaiswal
18.6k53158
18.6k53158
You are the man! Works perfectly now.
– Matthew Metros
14 hours ago
add a comment |
You are the man! Works perfectly now.
– Matthew Metros
14 hours ago
You are the man! Works perfectly now.
– Matthew Metros
14 hours ago
You are the man! Works perfectly now.
– Matthew Metros
14 hours ago
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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