quoted string value is quoted again
See original GitHub issueHi! I just found this solution for translation of xml to dict and is amazing!! Thanks a lot!
I tiny problem that i encountered is that a value like:
<lp>"/"</lp>
is translated to
"lp": "\"/\""
is there any way to not quote the string and just use it as is? Thanks a lot!
Issue Analytics
- State:
- Created a year ago
- Comments:9
Top Results From Across the Web
How to escape single quotes within single quoted strings
Enclosing characters in single quotes (''') preserves the literal value of each character within the quotes. A single quote may not occur between...
Read more >Example: Double-Quoted Strings
The basic double-quoted string is a series of characters surrounded by double quotes. If you need to use the double quote inside the...
Read more >'Single' vs "Double" quotes for strings in javascript - Flexiple
A double-quoted string can have single quotes without escaping them, conversely, a single-quoted string can have double quotes within it without ...
Read more >Quoting Strings with Single Quotes - Free Code Camp
As a developer, understanding the way strings work is very important. In this tutorial I go deeper into the value of quoting strings....
Read more >Quotes - R
Single quotes need to be escaped by backslash in single-quoted strings, ... The maximum allowed value for '\nnn' is '\377' (the same character...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@adriansev the key thing here is that quotes inside tags have no special meaning as far as the XML specification goes. They are just characters, and as far as the XML specification says, they are significant and should be treated as data, not as a container for a string. As far as the XML spec goes, you would represent the dict
{ "key": "my_string" }
as<key>my_string</key>
, not<key>"my_string"</key>
. The fact you have strings inside your XML that include quotes that are not actually part of the data within that tag is not something an XML parser should handle, as that’s not part of the XML specification; that’s a behavior of your application that is separate to the XML specification.As far as your request to add a special case
detect_quotes
flag into this library, the problem is that this then sets a precedent to extend the parser with features outside of the XML specification. What if another user then comes along and says that the data in their XML tags has single quote characters that need to be ignored? Or that the data inside the XML tags is URL encoded, and there should be anurl_decode
flag to ask the parser to decode URL encoded strings? Suddenly we end up with an explosion of features to deal with idiosyncrasies that are not actually part of the XML specification, that are dealing with the idiosyncrasies of the data stored within the XML.My suggestion to you is to treat this as a feature of the data you are handling, rather than something that should be a feature of an XML parser. Build a method or module to take the output of XML to dict mapping, and remove the quotes from the string values within the dictionary.
@SamStephens ok, got it, thanks a lot for your time and info!