I want to create an XML file which will be used to store the structure of a Java program. I am able to successfully parse the Java program and create the tags as required. T
You will have to escape
" to "
' to '
< to <
> to >
& to &
for xml.
In XML attributes you must escape
" with "
< with <
& with &
if you wrap attribute values in double quotes ("
), e.g.
<MyTag attr="If a<b & b<c then a<c, it's obvious"/>
meaning tag MyTag
with attribute attr
with text If a<b & b<c then a<c, it's obvious
- note: no need to use '
to escape '
character.
If you wrap attribute values in single quotes ('
) then you should escape these characters:
' with '
< with <
& with &
and you can write "
as is.
Escaping of >
with >
in attribute text is not required, e.g. <a b=">"/>
is well-formed XML.