c# - Invisible differences in XML files - breaking self-made XML parser -


i have 2 programs interact well-defined xml file. first program (model) reads in, parses it, , uses content file direct running of model. second program (controller) opens , rewrites xml file, allowing different settings run in model.

model written in c++, worked in vs2010 , vs2012, has no gui, , uses home-made (is correct term?) xml parser has worked many years without fail - checked svn revisions files make - nothing since 2013. controller written in c#, in vs2012, gui has drop downs set content of xml file, , uses xmldocument class read in, edit, , print out xml file .

suddenly, controller no longer spits out xml files can read model. when model tries read xml file, first character encounters reads '-17'. far have been able tell means doesn't recognize utf-8 character. cause model cout error , crash. older xml file (which looks identical ones written controller) reads in fine.

below examples of files - ignore content inside elements please. of may content might causing problem, i've checked again , again, , correct. , if content mattered, why parser in model fail @ first character ('<' = '-17') when reading in xmldocument created file?

older file:

<?xml version="1.0" encoding="utf-8" ?>  <config> <mode value="false" id="modeflag" /> <timestep outputtimestep="hourly"  calibrationtimestep="houry" /> <initialinput subcatchmentnumber="1" modelcalibration="true" snowsimulation="false" vegsimulation="method 1" catchmentnumber="1" fractionalcatchmentarea="1" /> <inputresource name="all" location="c:\autorun_newest\autorun" id="directory" /> <simulationscheme schemeforcatchmentno="8" infiltration="true" channelrouting="false" saturation="true" topographicindex="true" kdecaywithsoildepthexp="false" soiltopoindex="false" kdecayinpower="true" /> <snowinput inputcatchmentnumber="1" tempindexmethod_hourly="false" radiationtempindex_with_snowinterception="true" energybudgetmethod_with_snowinterception="false" /> <snowinputresource name="all" location="c:\autorun_newest\autorun" id="snowdirectory" /> <outputdirectory location="c:\autorun_newest\inputs\output_timestamp_07012015215112" name="toronto_output" /> </config> 

newer file:

<?xml version="1.0" encoding="utf-8" ?> <config>   <mode value="false" id="modeflag" />   <timestep outputtimestep="hourly" calibrationtimestep="hourly" />   <initialinput subcatchmentnumber="1" modelcalibration="true" snowsimulation="false" vegsimulation="method 1" catchmentnumber="1" fractionalcatchmentarea="1" />   <inputresource name="all" location="c:\autorun_newest\autorun" id="directory" />   <simulationscheme schemeforcatchmentno="8" infiltration="true" channelrouting="false" saturation="true" topographicindex="true" kdecaywithsoildepthexp="false" soiltopoindex="false" kdecayinpower="true" />   <snowinput inputcatchmentnumber="1" tempindexmethod_hourly="false" radiationtempindex_with_snowinterception="true" energybudgetmethod_with_snowinterception="false" />   <snowinputresource name="all" location="c:\autorun_newest\autorun" id="snowdirectory" />   <outputdirectory location="c:\autorun_newest\inputs\output_timestamp_07012015215112" name="toronto_output" /> </config> 

adding or taking away indentation (proper formatting xmldocument class in c#) changes nothing behavior of model.

these files visually identical, , can see no odd characters or spacing. invisible objects/forces/characters or other settings causing new bug?

is there background encoding xml document class enforces new home made parser?

you have byte order mark (bom) @ start of file. https://en.wikipedia.org/wiki/byte_order_mark

the bom unicode character u+feff, or in utf-8 bytes 0xef,0xbb,0xbf. 0xef -17 if reinterpret signed byte. many windows tools in particular put bom @ start of file if save it.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -