question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

quoted string value is quoted again

See original GitHub issue

Hi! 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:closed
  • Created a year ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
SamStephenscommented, Oct 4, 2022

@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 an url_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.

0reactions
adriansevcommented, Oct 5, 2022

@SamStephens ok, got it, thanks a lot for your time and info!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found