Welcome!

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

SignUp Now!

WAD @XMLXPATH fails when issued a second time

May
12,995
174
[See the recent thread in T&T\Miscellaneous.] Below, the same command fails when issued a second time. New instance of TCC31 ...

Code:
c:\users\vefatica\desktop> echo %@xmlopen[414.xml]
0

c:\users\vefatica\desktop> echo %@XMLXPATH[AccountingCustomerParty/Party/PartyTaxScheme/cbc:CompanyID]
53484421

c:\users\vefatica\desktop> echo %@XMLXPATH[AccountingCustomerParty/Party/PartyTaxScheme/cbc:CompanyID]
TCC: No such child. "AccountingCustomerParty/Party/PartyTaxScheme/cbc:CompanyID"

c:\users\vefatica\desktop>

XML file is attached.
 

Attachments

  • 414.zip
    1.5 KB · Views: 3
Yup, same here - JFI: after a reopen the file it works again ... so it seems %@xmlpath (maybe other similar commands too?) makes an undesired "%@xmlclose[]" ...
NOPE: no "%@xmlclose[]" - file is still open!

However: after %@xmlpath the nodes are immediately = 0 instead 19 ...
 
Last edited:
[See the recent thread in T&T\Miscellaneous.] Below, the same command fails when issued a second time. New instance of TCC31 ...

Code:
c:\users\vefatica\desktop> echo %@xmlopen[414.xml]
0

c:\users\vefatica\desktop> echo %@XMLXPATH[AccountingCustomerParty/Party/PartyTaxScheme/cbc:CompanyID]
53484421

c:\users\vefatica\desktop> echo %@XMLXPATH[AccountingCustomerParty/Party/PartyTaxScheme/cbc:CompanyID]
TCC: No such child. "AccountingCustomerParty/Party/PartyTaxScheme/cbc:CompanyID"

c:\users\vefatica\desktop>

XML file is attached.

WAD. You are not referencing the same location the second time. The first XPATH sets the relative location, the second one is trying to set another location relative to the first one.

You either need to address the XPATH from the root (i.e., with a leading '/'), or don't use @XMLOPEN (which will result in @XMLXPATH resetting the relative location each time).
 
Yup, ty, Rex!

Tested one of those variants:

Code:
echo %@XMLXPATH["414.xml",AccountingCustomerParty/Party/PartyTaxScheme/cbc:CompanyID]
53484421

and it works!

PS: Also the other variant works (of course):

Code:
echo %@xmlopen[414.xml]
echo %@XMLXPATH[/Invoice/cbc:UBLVersionID]
2.1
echo %@XMLXPATH[/Invoice/cbc:UBLVersionID]
2.1
 
Last edited:
OK, I'll have to think about that one. But what about @xmlnodes and @xmlnodenames? They do the same thing and neither lists the names. Below, I'm using the bookstore example from the help.

Code:
v:\> echo %@xmlopen[sample.xml]
0

v:\> echo %@xmlnodes[/bookstore]
4

v:\> echo %@xmlnodenames[/bookstore]
4

v:\> echo %@xmlclose[]
0
 

Similar threads

Back
Top