Retrieving XML attributes with XMLXPATH in v28

Aug 19, 2009
28
1
Hello

I have an XML file with the following structure

XML:
<Connect version='1.0'>
    <!-- ... -->
</Connect>

Prior to v28, I was using the following to retrieve the value of the 'version' attribute:

Code:
ECHO %@XMLXPATH["test.xml",/Connect/@version]

However, in v28 TCC is returning an error:

Code:
TCC:  "/Connect/@version"

I can work around this using a combination of XMLOPEN, XMLXPATH and XMLGETATTR, but is this a known issue in v28 or do I need to change the syntax of the original statement?

Thanks for your help!

Chris
 
May 20, 2008
11,867
121
Syracuse, NY, USA
It also fails in v27 (and works in v26). This (below) works in v28. I don't know enough about XML to say why it works or if there's some general principle at play here.

Code:
v:\> type xml.xml
<Connect version='1.0'>
    <!-- ... -->
</Connect>

v:\> ECHO %@XMLGETATTR["xml.xml",version]
1.0
 
Aug 19, 2009
28
1
Hello Vince!

Thanks very much for this, I can use this as a workaround as there is only one 'version' attribute in the XML document that I'm parsing. I suspect that the reason this is working is because the @XMLGETATTR function is operating on the root node by default when the filename is passed as an argument. I moved the attribute to a child node out of curiosity and it failed to find the attribute any more.

This is a good workaround though, so thank you again!

Chris