I'm using TinyXML in my application to save/open project file based on XML format.
I opened it and then save with new filename without any changes to the XML tree.
And as you can see below, some element in new file gets different format than in original.
1. I agree. XML supports double and single quotes. So I will try to find some solution.
2. Yes, I'd like to use such prettier structure for the <COORDSYS> but unfortunately I can't. This XML format is defined by ESRI company as ArcXML specification.
So, I have to stick to their guidelines.
The only thing I have to do is to figure out why ESRI's software does not support single quotes for attribute value as XML supports.
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
After a short investigation I revealed that " entity in attribute value is found as double-quote (") character only when compiling TinyXML in non-STL mode. But when I turn STL support on, then " entity seems to be preserved as is with no "conversion" to double-quote character. So, in STL mode everything works fine for me.
Here are my very simple changes I put to TinyXML in order to force TinyXML will act as I wish:
void TiXmlAttribute::Print( FILE* cfile, int /*depth*/ ) const
{
TIXML_STRING n, v;
Hi,
I'm using TinyXML in my application to save/open project file based on XML format.
I opened it and then save with new filename without any changes to the XML tree.
And as you can see below, some element in new file gets different format than in original.
Here is XML element <COORSYS> from original file:
<COORDSYS string="GEOGCS["GCS_WGS_1984",DATUM["WGS84",SPHEROID["WGS84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433]]"/>
but this is after TinyXML save XML tree (with <COORDSYS> to file:
<COORDSYS string='GEOGCS["GCS_WGS_1984",DATUM["WGS84",SPHEROID["WGS84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433]]' />
Please, note the difference in quotes.
The new version of <COORDSYS> gets single quotes around the attribute string. That's incorrect.
So, is this a bug in TinyXML?
I need it working a bit urgently, so please give me some guidelines how can I fix it.
Thanks in advance.
Cheers
No, thats not right, as far as I know and from doing some googling.
Both attrib="double" and attrib='single' quotes are acceptable.
If you have some need to have double quotes then the simplest solution is edit the source yourself.
But there is no XML-specific reason why that would be needed, AFAIK.
Off topic but I think it would be better to reorganise your XML a bit, e.g.
<COORDSYS>GEOGCS...</COORDSYS>
or even
<COORDSYS><GEOGCS>WGS_1984</GEOGCS>...</COORDSYS>
1. I agree. XML supports double and single quotes. So I will try to find some solution.
2. Yes, I'd like to use such prettier structure for the <COORDSYS> but unfortunately I can't. This XML format is defined by ESRI company as ArcXML specification.
So, I have to stick to their guidelines.
The only thing I have to do is to figure out why ESRI's software does not support single quotes for attribute value as XML supports.
Thanks
Ah, I have vague recollections of ESRI from years ago.
Its bound to be that they have a limited parser that they wrote themselves, thats all.
In this case it may warrant just hacking tinyxml a bit to get it to write out with the quote style you want.
Hi,
After a short investigation I revealed that " entity in attribute value is found as double-quote (") character only when compiling TinyXML in non-STL mode. But when I turn STL support on, then " entity seems to be preserved as is with no "conversion" to double-quote character. So, in STL mode everything works fine for me.
Here are my very simple changes I put to TinyXML in order to force TinyXML will act as I wish:
void TiXmlAttribute::Print( FILE* cfile, int /*depth*/ ) const
{
TIXML_STRING n, v;
PutString( name, &n );
PutString( value, &v );
if (value.find ('\"') == TIXML_STRING::npos)
{
fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() );
}
else
{
#ifdef TIXML_USE_STL
fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str());
#else
fprintf (cfile, "%s=\'%s\'", n.c_str(), v.c_str() );
#endif
}
}
Cheers
Mateusz