Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 2 Jahren, 2 Monaten
Letzter Beitrag:
vor 2 Jahren, 1 Monat
Beteiligte Autoren:
Victoria Caballero, kingdr, kingdr8

XMLREad vs Node

Startbeitrag von Victoria Caballero am 13.04.2016 09:50

Hello everybody,
here I am with a very strange issue processing an XML file.

I have a WD app which has a process reading XML files to extract some data related to products. So this process was working fine by using this code:
nSUP_GLN = XMLRead("MyXML","/catalogueItemNotificationMessage/transaction/documentCommand/catalogueItemNotification/catalogueItem/tradeItem/informationProviderOfTradeItem/gln")

Now the provider of the XML files has changed the strucure of the XML files and now this line is currently returning zero instead of the value in the attibute. So after investigating and struggling to get it working again I had to change my code for this one:
xNode = xmlFile.catalogueItemNotificationMessage.transaction.documentCommand.catalogueItemNotification.catalogueItem.tradeItem.informationProviderOfTradeItem.gln
nSUP_GLN = xNode..Text
and the right value is returned of course. But that means I need to change all the code in my program.

Can someone explain why? the path is actually the same in both coding formats but the first one says the path is wrong and returns zero and the second one is working fine.
Really do not understand the difference.

Any help or comment is welcome.

Thanks in advance.





Could you give more detail about this with a full layout of your xmlFile struct and
sample data, is it embedded or dynamically created...



von kingdr8 - am 14.04.2016 12:08
Hi King,
thanks for your reply.

The XML file is created by another company and they place the files in our FTP so we then read them and process them.

This is an overview of one of the paths I am reading as in the code example:
Maybe you can see something I do not :-).

Thanks again.



von Victoria Caballero - am 14.04.2016 13:39

IF the .xsd changed so does .xml, you have to change code to ensure node/element name
to be read in ... dot notation.

All I can show you is below:

cMyDoc is xmlDocument
cMyDoc.description = fLoadText("c:\xsd\books.xsd")
cMyDoc.person.lastname = "Moore"
cMyDoc.person.firstname = "Vince"
cMyDoc.person.dob = "19710211"
cMyDoc.person.email[1] = "vince.moore@mydomain.com"
cMyDoc.person.email[2] = "vince.moore@otherdomain.com"

info(cMyDoc.person.email[1] )
// will display vince.moore@mydomain.com

//based on Definition in person.xsd

// end person.xsd

Try read dynamically to read in element/node name,
even if the provider changed XSD structure, you could locate data accordingly.

Don't hardcode/embed in your wd project or you have to change all codes
in your project



von kingdr - am 14.04.2016 21:11
Hi King,
thanks for your response.
The problem is that the Provider of the XML never provided us with the XSD.
Now for the new version of the XML files they provide me with 70 different XSD files so now I am trying to figure out what should I do with them since I thought there was only one XSD file to describe the elements in an XML document.



von Victoria Caballero - am 20.04.2016 12:43

I'm afraid that you have to live with it for writing your own xml parser to overcome such.

I wonder if people move to JSON, have a look the link as below:


not much help, sorry :((


von kingdr - am 21.04.2016 02:41
Also have a look a link as below for dynamic creation to import XML data into
hyperfile with any creation of analysis .wdd.


Of course, bug is possible since I wrote it 6 yrs ago.




von kingdr - am 21.04.2016 02:48
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.