Method: XCAPClient::Client#get_attribute

Defined in:
lib/xcapclient/client.rb

#get_attribute(auid, document, selector, attribute_name, xml_namespaces = nil, check_etag = true) ⇒ Object

Fetch a node attribute from the document stored in the server.

Example, fetching the “name” attribute of the node with “id” = “sip:[email protected]”:

@xcapclient.get_attribute("pres-rules", nil,
  'cp:ruleset/cp:rule[@id="pres_whitelist"]/cp:conditions/cp:identity/cp:one[@id="sip:[email protected]"]',
  "name",
  {"cp" => "urn:ietf:params:xml:ns:common-policy"})

If success:

  • The method returns the attribute as a String.



367
368
369
370
371
372
373
374
375
376
377
# File 'lib/xcapclient/client.rb', line 367

def get_attribute(auid, document, selector, attribute_name, xml_namespaces=nil, check_etag=true)

  application, document = get_app_doc(auid, document)
  response = send_request(:get, application, document, selector + "/@#{attribute_name}", nil, xml_namespaces, nil, check_etag)

  # Check Content-Type.
  check_content_type(response, "application/xcap-att+xml")

  return response.body.content

end