Java DOM transforming and parsing arbitrary strings with invalid XML characters?

爱⌒轻易说出口 提交于 2020-01-21 11:49:08
问题 First of all I want to mention that this is not a duplicate of How to parse invalid (bad / not well-formed) XML? because I don't have a given invalid (or not well-formed) XML file but rather a given arbitrary Java String which may or may not contain an invalid XML character. I want to create a DOM Document containing a Text node with the given String , then transform it to a file. When the file is parsed to a DOM Document I want to get a String which is equal to the initial given String . I

How To Parse XML With Invalid Characters in Node Name?

旧巷老猫 提交于 2020-01-14 14:33:30
问题 So I'm trying to parse some XML, the creation of which is not under my control. The trouble is, they've somehow got nodes that look like this: <ID_INTERNAL_FEAT_FOCUSED_EXPERTISE_(MORNINGSTAR) /> <ID_INTERNAL_FEAT_FOCUSED_EXPERTISE_(QUARTERSTAFF) /> <ID_INTERNAL_FEAT_FOCUSED_EXPERTISE_(SCYTHE) /> <ID_INTERNAL_FEAT_FOCUSED_EXPERTISE_(TRATNYR) /> <ID_INTERNAL_FEAT_FOCUSED_EXPERTISE_(TRIPLE-HEADED_FLAIL) /> <ID_INTERNAL_FEAT_FOCUSED_EXPERTISE_(WARAXE) /> Visual Studio and .NET both feel that the

ASP.NET Invalid character in a Base-64 string

痞子三分冷 提交于 2020-01-12 08:28:23
问题 I recently implemented ELMAH on my site and I have noticed that we frequently get the "Invalid character in a Base-64 string" error. I have never triggered it myself and none of our users have complained about it so I don't know what is going on. From the little I was able to find about it it seems like the viewstate might be getting too big or becoming corrupted or something. Does anybody know what causes this and how to prevent it? Here are what I believe are the pertinent lines in the YSOD

filter/remove invalid xml characters from stream

一笑奈何 提交于 2019-12-24 04:56:13
问题 First things first, I can not change the output of the xml, it is being produced by a third party. They are inserting invalid characters in the the xml. I am given a InputStream of the byte stream representation of the xml. Is their a cleaner way to filter out the offending characters besides consuming the stream into a String and processing it? I found this: using a FilterReader but that doesn't work for me as I have a byte stream and not a character stream. For what it's worth this is all

removing invalid XML characters from a string in java

筅森魡賤 提交于 2019-12-17 03:31:28
问题 Hi i would like to remove all invalid XML characters from a string. i would like to use a regular expression with the string.replace method. like line.replace(regExp,""); what is the right regExp to use ? invalid XML character is everything that is not this : [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] thanks. 回答1: Java's regex supports supplementary characters, so you can specify those high ranges with two UTF-16 encoded chars. Here is the pattern for removing characters that are

SyntaxError: Invalid character '\u0008' message from the DOCTYPE tag

别来无恙 提交于 2019-12-11 14:07:50
问题 I am setting up a server and am getting a strange error I have never seen before: It is complaining about line 1 in the source, but that is just the DOCTYPE tag! <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <!-- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> --> ... As you can see I already tried setting the Content-Type to be something other than utf-8 . What is happening here? 回答1: The actual cause

Xhtml Invalid Characters?

六月ゝ 毕业季﹏ 提交于 2019-12-11 13:39:01
问题 I have made custom xhtml valdidator in .NET(validating through dtd + some extra rules) and I have noticed a discrepancy between my validation and w3c validation. In my validator I get the following error when there is colon in the id (let's say : id="mustang:horse") (Error) The 'id' attribute has an invalid value according to its data type. But I do not get any errors on w3c for this pattern. I tried to find a list of invalid characters for an attribute in xml/xhtml but couldn't find it?

c# Registry to XML Invalid character issue

夙愿已清 提交于 2019-12-11 04:09:09
问题 I have a problem when trying to create an XML file from registry. On my laptop(W7 64b) it is working fine, the xml file is generated but on another computer (Xp 32b) an exception is thrown : System.ArgumentException '.', hexadecimal values 0x00, is an invalid character. I have read few useful things about it but I don't know how to solve in this case, here is the code : try { string regPath = "SOFTWARE\\IPS"; XElement xRegRoot = new XElement("Root", new XAttribute("Registry", regPath));

How to stop XMLReader throwing Invalid XML Character Exception

谁都会走 提交于 2019-12-09 17:58:29
问题 So I have some XML: <key>my tag</key><value>my tag value &#xB;and my invalid Character</Value> and an XMLReader: using (XmlReader reader = XmlReader.Create(new StringReader(xml))) { while (reader.Read()) { //do my thing } } I have implemented the CleanInvalidCharacters method from here but as the "&#xB" is not yet encoded it doesn't get removed. The error is being thrown at the reader.Read(); line with exception: hexadecimal value 0x0B, is an invalid character. 回答1: The problem is that you

SCRIPT1014: Invalid character - Quote symbol

a 夏天 提交于 2019-12-07 10:31:23
问题 I have this problem: array[i].idAuthor is a String variable. I want to pass this String to a function which is called inside an append-String. The code works fine in Chrome and Firefox except for Internet Explorer. IE gives me this error: SCRIPT1014: Invalid character I think the issue are the `-Quotes . I hope the following example helps to express my problem. <script> (...) $("#id").append("<div onClick='myFunc(`" + array[i].idAuthor + "`);'>" + i + "</div>"); (...) <script> Is there