Character reference "&#26" is an invalid XML character.

Hi, I got above error when I use XmlRpcClient. Here is the way to reproduce on confluence 3.5.7:

1. Add a page (with title contains char "" , e.g. "Test page I subbed it") to a space;
2. Pass the space key and other parameters to following function:

public Object call(String username, String password, String spaceKey, URL serverURL)
{
Object obj=null;
try
{
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(serverURL);
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
Object[] parameters = new Object[]{username, password};
String token = (String) client.execute("confluence1.login", parameters);
Vector<Object> args = new Vector<Object>();
args.add(spaceKey);
args.add(0,token);
obj = client.execute("confluence1.getPages", args);
}
catch (XmlRpcException xe)
{
xe.printStackTrace();
}
return obj;
}

then you will get following calling stack:

06/07/2011 10:27:35 [6] org.apache.xmlrpc.client.XmlRpcClientException: Failed to parse server's response: Character reference "&#26" is an invalid XML character.
06/07/2011 10:27:35 [6] at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:180)
06/07/2011 10:27:35 [6] at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:148)
06/07/2011 10:27:35 [6] at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:115)
06/07/2011 10:27:35 [6] at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
06/07/2011 10:27:35 [6] at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
06/07/2011 10:27:35 [6] at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
06/07/2011 10:27:35 [6] at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:158)
06/07/2011 10:27:35 [6] at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:147)

How to resolve this problem?

Thanks in advance!!!

Peter

2 answers

&#26 is a control character. Control charcters are not legal xml, and confluence's parser is not going to be able to handle it. So, uploading content with this sort of character using the remote api is not going to work. You'll have to excise the character from your content if you are using the remote api.

See also:
http://lists.xml.org/archives/xml-dev/199804/msg00502.html
http://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml

Hi Laura, Thanks a lot for your reply! I know &#26 is a control char, but question is: Confluence allows control char in page title and provides an API method "getPages" which could NOT return correct results in this case. Do you know any other ways that "getPages" could be used successfully in this case? Your help is greatly appreciated.

Best wishes,

Peter

here is one post which may help you to find control charectors :

for my case i could able to figure out the control charectors with the help of notepad++

https://studio.plugins.atlassian.com/wiki/display/UWC/UWC+F.A.Q. :

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Published 10 hours ago in Confluence

Think you know shares vs. @mentions in Confluence? Take this collab quiz.

To anyone who doubts that Atlassians are a little too obsessed with collaboration, and tools related thereto, let me describe a recent discussion we had (which took place on our internal Confluence, ...

92 views 2 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you