How to access XML *attributes* using XPath

May 21, 2008
20
0
Berne, Switzerland
Folks,
Let's say I have a XML fragment like this:

<Requester>
<ApplicationID application="OMS_SERVICE" bo="Client" />

How can I access the value of the "application" attribute in TakeCommand??

From what I can see, the XMLXPATH function in TCMD 9 (and from the looks of it - in TCMD 10, too) can only read and write element values - but not attributes.

Really?!?!? This seems like a severe limitation, really - XML documents typically are mixed collections of elements and attributes.

Or am I missing something here??

Cheers! Marc
 

rconn

Administrator
Staff member
May 14, 2008
12,404
152
mscheuner wrote:


> Let's say I have a XML fragment like this:
>
> <Requester>
> <ApplicationID application="*OMS_SERVICE*" bo="*Client*" />
>
> How can I access the value of the "application" attribute in TakeCommand??

You cannot; Take Command does not currently support retrieving XML
attributes.


>>From what I can see, the XMLXPATH function in TCMD 9 (and from the looks of it - in TCMD 10, too) can only read and write element values - but not attributes.
>
> Really?!?!? This seems like a severe limitation, really - XML documents typically are mixed collections of elements and attributes.
>
> Or am I missing something here??

I'll add it to the suggestion list for v11, but so far you're the only
user who's asked for it.

Rex Conn
JP Software
 
May 29, 2008
571
4
Groton, CT
Folks,
Let's say I have a XML fragment like this:

<requester>
<applicationid application="<b>OMS_SERVICE</b>" bo="<b>Client</b>">

How can I access the value of the "application" attribute in TakeCommand??

From what I can see, the XMLXPATH function in TCMD 9 (and from the looks of it - in TCMD 10, too) can only read and write element values - but not attributes.

Really?!?!? This seems like a severe limitation, really - XML documents typically are mixed collections of elements and attributes.

Or am I missing something here??

Cheers! Marc


Here's a clue:

File X.XML :

<foo>
<bar>
<baz whatzit='frob'>
</baz>
</bar>
</foo>


> echo answer=%@xmlxpath[".\x.xml",foo/bar/baz/@whatzit]
answer=frob


You can access an attribute with the same syntax an item by prefixing the attribute name with an '@'.

Rex has disclaimed support for this, but I've been using it consistently without a problem.


</applicationid></requester>
 
May 21, 2008
20
0
Berne, Switzerland
Here's a clue:
> echo answer=%@xmlxpath[".\x.xml",foo/bar/baz/@whatzit]
answer=frob
You can access an attribute with the same syntax an item by prefixing the attribute name with an '@'.

Ah, yes - look at that - that's the standard XPath syntax, and I had tried it before (but that was still in TCMD v8 and it hadn't worked back then).

But now in TCMD v9, this works like a charm - thanks!

Rex: no need to consider for v11 - it's already in there :-)

Thanks guys
Marc
 
Similar threads
Thread starter Title Forum Replies Date
Jesse Heines Access Denied errors in TCC 27 Support 9
Jay Sage Directory Alias Access to FTP Servers Support 2
vefatica "Access denied" messages from DO Support 3
O TPIPE: Error -Can´t access textpipeengine.dll Support 24
C How to? Setting up SMTP access for Yahoo with TCMD v20 Support 7
dcantor Unable to access help Support 9
P Access denied TakeCommand.19.0.key Support 2
D How to? How to access iPhone from tcmd.exe? Support 1
vefatica TPIPE access violations are back Support 2
vefatica TPIPE access violation again Support 1
vefatica TPIPE: Access violation Support 5
S WAD Cannot access mapped drive in 64b Win7 Support 15
C registration proboem if no internet access given Support 0
cgunhouse TPIPE: Error - Can't access textpipeengine.dll Support 14
P Can't access textpipeengine.dll Support 11
Q TCC: (Sys) The process cannot access the file because it is being used by another process. Support 0
C Cannot register v12.10 without Internet access Support 19
vefatica Random access to the characters in a string? Support 4
S How to access array elements? Support 5
S FTP site; IFTP access Support 10
Roedy tccbatch Windows 7 "access is denied" Support 4
T Access violation upon TC startup Support 2
M Testing my e-mail access Support 1
p.f.moore Broken email access to these forums - finally giving up Support 4
K_Meinhard Email access, again Support 2
K_Meinhard email access Support 6
rconn Email access Support 6
C access denied problem under Vista Support 5
vefatica Need help with XML Support 3
vefatica Documentation Help: XML link still broken Support 0
MickeyF Trying to read XML Support 3
C Unsuppressable errors from XML functions Support 5
Kachupp Colour Attributes Support 2
Alpengreis How to? Copy DIRs with attributes ... Support 4
mfarah Fixed TCC seems to dislike the P and U attributes. Support 2
vefatica del, attributes, et c. Support 0
R Delete command sets directory attributes to hidden & system Support 46
S COPYing attributes Support 3

Similar threads