Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Word复制/粘贴时,Java XML解析器错误Unicode 0x1A无效字符_Java_Xml_Unicode_Xml Parsing_Sax - Fatal编程技术网

从Word复制/粘贴时,Java XML解析器错误Unicode 0x1A无效字符

从Word复制/粘贴时,Java XML解析器错误Unicode 0x1A无效字符,java,xml,unicode,xml-parsing,sax,Java,Xml,Unicode,Xml Parsing,Sax,对不起,我重复了邮件。但我之前的文章是基于Flex的: 但是现在我在Java端发布这个 问题是: 我们有一个电子邮件功能(应用程序的一部分),我们在其中创建一个XML字符串并将其放入队列。另一个应用程序接收它,解析XML并发送电子邮件 当电子邮件文本(..您是否尝试使用TagSoup/JSoup/JTidy等XML库来清理XML时,我们遇到了一个XML解析器异常?无效(隐藏)字符来自UI(Flex TextArea).So必须在UI中处理它,这样它就不会传递给Java。使用Flex textA

对不起,我重复了邮件。但我之前的文章是基于Flex的:

但是现在我在Java端发布这个

问题是:

我们有一个电子邮件功能(应用程序的一部分),我们在其中创建一个XML字符串并将其放入队列。另一个应用程序接收它,解析XML并发送电子邮件


当电子邮件文本
(..您是否尝试使用TagSoup/JSoup/JTidy等XML库来清理XML时,我们遇到了一个XML解析器异常?

无效(隐藏)字符来自UI(Flex TextArea).So必须在UI中处理它,这样它就不会传递给Java。使用Flex textArea中的chagingHandler来限制字符,处理并删除它。

Tim,我只需要生成XML字符串。另一个应用程序(我们无法控制)获取字符串并对其进行解析。我可以使用这些技术中的任何一种生成字符串吗?我敢打赌,将您的XML输入其中一个库并使用经过清理的结果将解决您的问题。首先使用XML库来构造XML可能是一个更好的主意。Tim我正在尝试使用JTidy,但无法使其正常工作但是,还有其他XML库来构建XML吗?
Invalid character in attribute value BODY (Unicode: 0x1A)
body = body.replaceAll("‘", "");
body = body.replaceAll("’", "");
public String stripNonValidXMLCharacters(String in) {
        StringBuffer out = new StringBuffer(); // Used to hold the output.
        char current; // Used to reference the current character.

        if (in == null || ("".equals(in))) {
            return ""; // vacancy test.
        }
        for (int i = 0; i < in.length(); i++) {
            //NOTE: No IndexOutOfBoundsException caught here; it should not happen.
            current = in.charAt(i); 
            if ((current == 0x9) 
                    || (current == 0xA) 
                    || (current == 0xD) 
                    || ((current >= 0x20) && (current <= 0xD7FF)) 
                    || ((current >= 0xE000) && (current <= 0xFFFD)) 
                    || ((current >= 0x10000) && (current <= 0x10FFFF)))
                out.append(current);
        }
        return out.toString();
    }
private String stripNonValidXMLCharacter(String in) {      
        if (in == null || ("".equals(in))) { 
            return null;
        }
        StringBuffer out = new StringBuffer(in);
        for (int i = 0; i < out.length(); i++) {
            if (out.charAt(i) == 0x1a) {
                out.setCharAt(i, '-');
            }
        }
        return out.toString();
    }
 emailText = emailText.replaceAll("[\\u0000-\\u0008\\u000B\\u000C" 
                        + "\\u000E-\\u001F" 
                        + "\\uD800-\\uDFFF\\uFFFE\\uFFFF\\u00C5\\u00D4\\u00EC"
                        + "\\u00A8\\u00F4\\u00B4\\u00CC\\u2211]", " ");
            emailText = emailText.replaceAll("[\\x00-\\x1F]", "");
            emailText = emailText.replaceAll(
                                    "[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]", "");
            emailText = emailText.replaceAll("\\p{C}", "");
 <?xml version="1.0" encoding="UTF-8"?>  
                    <EMAILS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNameSpaceSchemaLocation=".\\SMTPSchema.xsd\">
Text......text
<newLine>
<tab><tab><tab> text...text
<newLine>
<?xml version="1.0" encoding="UTF-8"?> <EMAILS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNameSpaceSchemaLocation=".\SMTPSchema.xsd"> <EMAIL SOURCE="t@t.com" DEST="t@t.com" CC="" BCC="t@t.com" SUBJECT="test 61" BODY="As such there was no mechanism constructed to migrate the enrollment user base to Data Collection or to keep security attributes for common users in sync between the two systems.  The purpose of this document is to outline two strategies for bring the user base between the two applications into sync.?  It still is the same.  ** Please note: This e-mail message was sent from a notification-only address that cannot accept incoming e-mail. Please do not reply to this message."/> </EMAILS>