Welcome! Log In Create A New Profile

Advanced

xml document error

Posted by cabinetman 
xml document error
February 18, 2019 05:33PM
Hello All,

I am using the xml document variable to parse a xml file with 37,000 lines.

I have been doing this for a year with no issues until last week when I left for vacation.

I am getting this error:
Row 581, Column 67: Input is not proper UTF-8, indicate encoding !
Bytes: 0xA0 0x3C 0x2F 0x50
When this error happens it will not load the xml file into the varible.

What is the cause is a space at the end in this PO tag. After the BBAP there is a space. to test this I first opened the file with loadtext then did a find and replace of the "BBAP " to "BBAP" and removed the space. Then the error went away.
<PONumber>C2018 4TH QRTR BBAP </PONumber>

But I can not code just that 1 find and replace because if the PO changes but still has a space it will not work.

Is there any way to find a empty space at the end of a string inside a tag?

DW
Re: xml document error
February 18, 2019 06:07PM
Hi,

Before you start changing your code, you don't say if the space always been there (in one form or another; ie. UTF-8 or otherwise), or if the sender has changed something at their end?

Regards,
Darren.
Re: xml document error
February 18, 2019 07:05PM
Hello Darren,

No the space at the end of the string has never been there before and apparently if you have a empty space at the end of a string in between two tags it will throw an error.

The space is human error on the end of the user who is inputting the data in the system that generates the xml file. This has only happened once but with my luck it will happen again. Unfortunately for me I am afraid this will happen again.

I would like to call them up and ask them to correct it but once the data is inputted into the system that generates the xml file it can not be changed.

So my only choice for now is to find a way to get rid of the space or every time this occurs have to add a line of code for each different occurrence.

DW
JP
Re: xml document error
February 18, 2019 07:16PM
DW

Perhaps you can run it through a first pass inside an When Exception construct and if the exception triggers only then look for the offending space. This will save since as you say this has been fine for a year so it is the exception and not the rule.

JP
Re: xml document error
February 18, 2019 07:33PM
Hi,
Are they using your system to create and send the file?
If so, then trim the space before the file is sent
...or...
If the PONumber field is always in the format you mentioned, then you can trim the space once it's arrived.
... otherwise...
You can do as JP mentioned

Regards,
Darren.
Re: xml document error
February 18, 2019 07:54PM
Hello Darren,

No they are not.

DW
pao
Re: xml document error
February 18, 2019 08:04PM
I don't know if it helps but after the floadtext you can replace space</ by </ to remove the space at the end of the tag.

Regards

Paulo Oliveira
Re: xml document error
February 18, 2019 08:06PM
Hello Paulo,

Yes that will work.

DW



Edited 1 time(s). Last edit at 02/18/2019 08:09PM by cabinetman.
Re: xml document error
February 18, 2019 09:26PM
Hello All,

Well the replace " </" did not work so what I ended up doing was:

        sXmlcode is string  = fLoadText(NameXMLFile)
	sUTF_ToAnsi is string = UTF8ToAnsi(sXmlcode)
// Open the XML file
	xmlDoc is xmlDocument
	xmlDoc = XMLOpen(sUTF_ToAnsi, fromString)

This replaces the space (0xA0 in UTF-8) with a question mark and I an live with that.
I am sure it has something to do with the fact the the file is encoded in UTF-8

DW
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: