Folks,
Since I posted I wrote a method to strip the XML declrataion in case it
benifits anyone. Note it has not seen extensive testing but seems to do
the trick for me:
/**
* Removes the <?xml version="1.0"?> decalaration from XML string
*/
public void removeXMLDeclaration(StringBuffer str) {
int len = str.length();
int startIndex = -1; //start of what we are removing
int endIndex = -1; //end of what we are removing
for (int i=0; i<len; i++) {
if (str.charAt(i) == '<') {
startIndex = i;
//Skip spaces after '<'
i++;
while (str.charAt(i) == ' ') {
i++;
}
if (str.charAt(i) == '?') {
//We have an XML declaration to remove
//Skip forward and find matching '>'
while (str.charAt(i) != '>') {
i++;
}
endIndex = i;
break;
}
else {
//Not an XML declaration
startIndex = -1;
break;
}
}
}
str.delete(startIndex, endIndex+1);
}
Farrukh Najmi wrote:
> I am marshaling a Castor object to be enclosed within a SOAP message.
> The marshal method outputs the XML declaration like:
>
> <?xml version="1.0"?>
>
> at the top of the output. Is there a way to tell Castor to not do that
> since when it is in the middle if a SOAP message it causes errors in
> parsers.
>
> Alternatively does anyone have code they can share that strips the XML
> declaration out? Thanks.
>
> --
> Regards,
> Farrukh
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
--
Regards,
Farrukh
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev