Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to include greater than or less than signs in an XML file?

Tags:

xml

I have an XML file from a client that has greater than > and less than < signs in it and it fails an XML format check. Is there a way to get around this without asking the client to fix the file?

e.g.

<?xml version="1.0" encoding="UTF-8"?>  <note Name="PrintPgmInfo <> VDD">  <to>Tove</to>  <from>Jani</from>  <heading>Reminder</heading>  <body>Don't forget me this weekend!</body> </note> 
like image 650
Mookayama Avatar asked Apr 01 '15 19:04

Mookayama


People also ask

How do you add greater than or equal to in XML?

<= and >= or ≥ and ≤ ? Just use &gt;= and &lt;= .

How do I pass the greater than symbol in XML?

Just &lt; and &gt; . If you need an 'equals', simply append a = character.

How do I add special characters to an XML file?

To include special characters inside XML files you must use the numeric character reference instead of that character. The numeric character reference must be UTF-8 because the supported encoding for XML files is defined in the prolog as encoding="UTF-8" and should not be changed.


2 Answers

You may try to use it like this:

< = &lt;  > = &gt; 

These are known as Character Entity References

like image 152
Rahul Tripathi Avatar answered Sep 16 '22 18:09

Rahul Tripathi


You will have to use XML escape characters:

" to  &quot; ' to  &apos; < to  &lt; > to  &gt; & to  &amp; 

Google escaping characters in XML for more information.

like image 33
david tallon Avatar answered Sep 19 '22 18:09

david tallon