Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

SRP_Extract_XML and OSRead

Apologies in advance. I am a brand new OpenInsights / SRP user so I am still finding my feet on how everything works!

I am having an issue with SRP_Extract_XML which may turn out to be more of a OSRead byproduct.
SRP_Extract_XML was refusing to read XML (grabbed via OSRead from a valid well-formed XML file).

This is my method:
OSOpen filename to inputFileHandle then OsRead CSV from inputFileHandle then xpath = '/PathToElement' XmlSource = CSV WorkPlace = SRP_Extract_Xml(XmlSource, XPath)

I quickly tracked my issue down to file encoding differences.
OSREAD on a valid UTF-8 XML file looks like this:

OSREAD on the same file saved as ANSI looks like this:

SRP_Extract_Xml is OK reading the latter. It can (understandably I guess) not read the former due to the preceding characters highlighted.

I guess my question then is related to my process. If OSRead is going to behave differently based on file encoding is that the best way to source my data for SRP_Extract_XML to do its' work?


  • Oops. I just noticed my example code doesn't match my image. Please ignore the xpath variable in relation to the image. I know they are mismatched :) My issue is the XMLSource isn't being processed so xpath isn't even relevant at this stage!
  • That appears to be a Byte Order Mark (BOM). OSRead does not support recognition and removal of BOMs. Thus, you have to look for this leading UTF-8 sequence yourself, and subsequently remove it, before passing it to SRP_Extract_Xml.

    Also, make sure to enable UTF8 character mode in OpenInsight's Application Properties (which you can find in OI's File menu).
  • Kevin, that was it exactly. I am not sure how I survived so long without coming across that before but now I know all about it! 2 lines of code and it is no longer a problem.....

    What does the UTF8 property do here. My OI help file (9.3.2 and 9.4) refuses to load that particular link for some reason.
  • It tells OI that variables are to be treated as UTF-8 encoded instead of ASCII encoded. This comes into play any time OI needs to convert to Unicode, such as when pushing a variable into a control or passing variables to Unicode APIs.
  • Understood. Thanks Kevin.
Sign In or Register to comment.