-2

for values. Can anyone please tell me to parse value "<" using minidom.parse in python.

 <Value>"&lt;"</Value> </Root> 
4
  • 1
    May I know what output exactly you wants here ? Commented Dec 11, 2013 at 4:46
  • i send a request xml with "<" character for which i get response xml as above. Now i want to extract the "<" character for matching with those sent in request xml. Commented Dec 11, 2013 at 4:49
  • 1
    Not sure if it got lost in the edit or not, but </ResourceRecordSets> was also missing from the 2nd to last line of your XML. Again, ensure you're working with valid XML before trying to parse. Commented Dec 11, 2013 at 4:57
  • you could try regex-based solution to convert your xml-like input into xml to be parsed by minidom later. Commented Dec 11, 2013 at 5:07

1 Answer 1

2

Thats not valid XML, " and < are a special characters in XML and can't be included in a document like that.

Fix your XML by escaping the " and < symbols and minidom will work as expected.

For example:

<Value>&quot;&lt;&quot;</Value> 

or:

<Value><![CDATA["<"]]></Value> 
Sign up to request clarification or add additional context in comments.

3 Comments

For OP: There are several online xml validators/formatter available to you as well to check your source for errors. An example of one: freeformatter.com/xml-formatter.html
The code is modified in such a way that it takes < inside quotes "" and updates to sqlserver as "<". Now when response is received the value("<") is present as such in response xml. So i need to parse whole value("<") for a further match.
@user3087993 You can't. That is not XML. If you have a < character in your text file thats not part of an element, by definition *it isn't XML as it isn't conforming to the XML spec. Fix your XML. The problem isn't your code, its your XML. Can I make that clearer?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.