Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error to copy content of XML file to Cursor
Message
From
09/02/2022 00:22:42
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
08/02/2022 17:50:42
Luis Santos
Biglevel-Soluções Informáticas, Lda
Portugal
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01683464
Message ID:
01683493
Views:
35
>Luis,
>check
>
?VARTYPE(dossiersnew.u_glnentr),VARTYPE(dossiersnew.qtt),
>looks like the fields get translated to something different then character.
>
>If you check the xml, for example the one I send you
>
><?xml version="1.0" encoding="iso-8859-1"?>
><xml>
>	<item>
>		<bostamp>Adm22020730717,977000001</bostamp>
>		<bistamp>Adm22020730718,046000002</bistamp>
>		<ref>DIFGB2L</ref>
>		<qtt>1.0000</qtt>
>		<lote/>
>		<obrano>36</obrano>
>		<design>PC Gold&amp;Blue Porcelain 2L Diffuser Bottle (Empty)  </design>
>		<lordem>10000</lordem>
>		<u_glnentr>5600000025888</u_glnentr>
>		<dataobra>2022-02-05 00:00:00.000</dataobra>
>	</item>
>
>
>u_glnentr looks like a number, qtt as well.
>
>If you don't give a (xml) schema, VFP will guess the field type - and might guess wrong. I would guess a number anyway, so why not poor VFP?
>
>Try to create the cursor first and then use flag 8192 for XMLTOCURDSOR, see help to XMLTOCURSOR. Read the stuff about 8192 and schema with some care.
>
>Or try to add a schema to the XML expected via string operation in front of the data, use CURSORTOXML to create a valid one and check for the structure.
>
>Lutz
>
>Hi Lutz,
>
>I will go to try your suggestion about using VARTYPE(), also, i always thinking that anythings inside XML Tags are always character even though the tag contained only numbers.
>I´am was wrong and I'm sure that always checking vartype will save you headaches in the future :)
>
>Best regards and many thanks for your help!!
>
>Luis

Luis,

I think, that VARTYPE() etc is just a kludge to figure out what is wrong.

What I would do (example, running, you can replace with xml-file)
clear
TEXT TO lcXML  noshow
<?xml version="1.0" encoding="iso-8859-1"?>
<xml>
	<item>
		<bostamp>Adm22020730717,977000001</bostamp>
		<bistamp>Adm22020730718,046000002</bistamp>
		<ref>DIFGB2L</ref>
		<qtt>1.0000</qtt>
		<lote/>
		<obrano>36</obrano>
		<design>PC Gold&amp;Blue Porcelain 2L Diffuser Bottle (Empty)  </design>
		<lordem>10000</lordem>
		<u_glnentr>5600000025888</u_glnentr>
		<dataobra>2022-02-05 00:00:00.000</dataobra>
	</item>
</xml>
ENDTEXT &&lcXML 

CREATE CURSOR dossiersnew (;
	bostamp   c(25),;
	bistamp   c(25),;
	ref       c(10),;
	qtt       n(20,5),;
	lote      c(10),;
	obrano    c(10),;
	design    c(120),;
	lordem    c(20),;
	u_glnentr c(15),;
	dataobra  T)

XMLTOCURSOR(m.lcXML,'dossiersnew',8192)
or. with more control like
clear
TEXT TO lcXML  noshow
<?xml version="1.0" encoding="iso-8859-1"?>
<xml>
	<item>
		<bostamp>Adm22020730717,977000001</bostamp>
		<bistamp>Adm22020730718,046000002</bistamp>
		<ref>DIFGB2L</ref>
		<qtt>1.0000</qtt>
		<lote/>
		<obrano>36</obrano>
		<design>PC Gold&amp;Blue Porcelain 2L Diffuser Bottle (Empty)  </design>
		<lordem>10000</lordem>
		<u_glnentr>5600000025888</u_glnentr>
		<dataobra>2022-02-05 00:00:00.000</dataobra>
	</item>
</xml>
ENDTEXT &&lcXML 

CREATE CURSOR dossiersnew (;
	bostamp   c(50),;
	bistamp   c(50),;
	ref       c(50),;
	qtt       c(50),;
	lote      c(50),;
	obrano    c(50),;
	design    c(50),;
	lordem    c(50),;
	u_glnentr c(50),;
	dataobra  c(50),;
;
 nqty      n(20,5),;
 tdataobra T)

XMLTOCURSOR(m.lcXML,'dossiersnew',8192)

REPLACE ALL;
nqty      with VAL(qtt),;
tdataobra with DATETIME(;
VAL(getwordnum(STREXTRACT(dataobra,'',' ',1),1,'-')),;
VAL(getwordnum(STREXTRACT(dataobra,'',' ',1),2,'-')),;
VAL(getwordnum(STREXTRACT(dataobra,'',' ',1),3,'-')),;
VAL(getwordnum(STREXTRACT(dataobra,' ','',1),3,':')),;
VAL(getwordnum(STREXTRACT(dataobra,' ','',1),3,':')),;
VAL(getwordnum(STREXTRACT(dataobra,' ','',1),3,':')))

*proceed like your old code
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform