Character reference "&#26" is an invalid XML character.
Asked by Peter Al:

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


Answers:
author: Laura Kolker
body: \&#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

comments: author: Peter Al
body: 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


author: Qualcomm Support
body: 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.> :


Tags: validation

xml

xml-rpc