Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Getting a tag attribute value in ACL?


Getting a tag attribute value in ACL?

I am trying with little success to read an attribute value for a tag in a topic using ACL. This is the script that I am using:

$othermeta = tag_attr_value('othermeta', 'content', current_doc());
message "content: $othermeta";

It does not return a value for $othermeta, even though the topic I'm reading has this tag. Am I misusing the tag_attr_value method or is there a better way to do this? There could be zero or more <othermeta> tags in the topic. I have confirmed that current_doc() is referencing the expected topic.

I wasn't able to find a method in ACL that is similar to the following call in JavaScript that makes it easy to parse the tags:
var othermetas = doc.getElementsByTagName('othermeta');

It is preferable for me to do this in ACL.

The topic contains content like this:

<topic id="accessibility_enabling" otherprops="none" product="all"&lt;br"/>xmlns:atict="
<title><ph id="topic-title">Enabling Accessibility Mode</ph></title>
<indexterm>Accessibility<indexterm>accessibility mode</indexterm></indexterm>
<othermeta content="Campaigns_and_Leads" tasks_and_calendar&quot;<br="/>name="app_area"/>
<othermeta name="user_role"...

More content here


Any help is appreciated.


Hi Mark-

You want to read a value from a specific instance of <othermeta>, right?
I think you want to do something like this:

local $metas[];


# $metas array now contains list of all othermeta elements in current

for ($i in $metas) {

response("The " . $i . "th othermeta has name=" .
oid_attr($metas[$i],'name') . ", content=" .


So, oid_find_children() is the ACL analog of the DOM
getElementsByTagName() function.



For sake of clarification, the tag_* functions in ACL are all about getting
document type (DTD or Schema) information, so I think you'd only have gotten
a result from this function if a value was specified in the DTD, somehow.
Just for variety of approach, you might also consider using the XPath
functions, such as the following, which would return the value of the
"content" attribute on the first "othermeta" element in the current

xpath_string("//othermeta[1]/@content", current_doc())

However, I recall some discussion a while back regarding the efficiency of
the XPath functions compared to the more "native" oid-based functions, so
Clay's solution would probably be faster.

-Brandon 🙂

Top Tags