Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Error 208 : No such child with @XMLXPATH

I am confused about using XML parsing. The appended file (which is in fact an xml file) represents an electronic invoice used in my country starting by this year.
I am trying to extract some info from that file. Such as the string 53484421 which is the tax ID.
I am using the TCC console :
<<echo %@XMLHASXPATH[cac:AccountingCustomerParty/Party/PartyTaxScheme/cbc:CompanyID]>> returns 1.
Instead @XMLXPATH returns <<TCC: No such child.>> Quite annoying.
But the surprise comes (at least for me). I was accidentally set a mistaken path : @XMLXPATH[/AccountingCustomerParty/Party/PartyTaxScheme/cbc:CompanyID] which returns an error <<TCC: Top element does not match..>> Right after that I have made the same inquiry on the correct path [cac:AccountingCustomerParty/Party/PartyTaxScheme/cbc:CompanyID] which returns me the expected string !
Again : @XMLOPEN - @XMLXPATH (correct path ) returns error 208. But @XMLOPEN - @XMLXPATH (wrong path) with the normal error - followed by @XMLXPATH (correct path) returns the string.
These are two sequencies quite strange.

Another situation. In a batch file.
set a=%@XMLOPEN[file.xml]
set t=%@XMLHASXPATH[path-one]
if %t EQ 1 set CAR1=%@XMLXPATH[path-one]
if %t EQ 2 set CAR1=%@XMLXPATH[path-two]
I never succeded to get a result, only error. Error 208 : No such child. Even if the answer for %t% was 1.

I suppose I am wrong somewhere. Does anyone know which is my mistake, please ?

Thank you,
Florin
 

Attachments

  • 414.TXT
    5.6 KB · Views: 4
set a=%@XMLOPEN[file.xml]
set t=%@XMLHASXPATH[path-one]
if %t EQ 1 set CAR1=%@XMLXPATH[path-one]
if %t EQ 2 set CAR1=%@XMLXPATH[path-two]

What are "path-one" and "path-two"?

According to the help, @XMLHASXPATH[] can only be 1 or 0 (it can't be 2).
 
I never made "live" such a childish mistake. It was a typing error in my exposal.
In my case the element "53484421" could be found in more locations.
Path-one is the more probable location from where could be retrieved the element (the main location) and parth-two is the secondary one.
For example the main location is [cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID] used with @XMLHASXPATH.
But the absolute value of path is not relevant for the case.

Using directly (not after testing with @XMLHASXPATH) the main path : set CAR1=%@XMLXPATH[path-one] works fine.
However I need to try the secondary path - when @XMLHASPATH or @XMLXPATH return 0.
I thought a normal iteration with IF could work. If %t=1 - use the main path & if %t=0 - use the 2nd path. It doesn't works.

Florin
 
Back
Top