module Hpricot

Extensions to the Hpricot XML parser.

Public Instance Methods

basename() click to toggle source
# File lib/davclient/hpricot_extensions.rb, line 93
def basename
  File.basename(self.at("d:href").innerText)
end
content() click to toggle source

Get content from resources on server Example:

webpage = WebDAV.find("http://example.org/index.html")
print "html src: " + page.content
# File lib/davclient/hpricot_extensions.rb, line 39
def content
  if(!isCollection?)
    WebDAV.get(self.at("d:href").innerText)
  end
end
content=(string) click to toggle source
# File lib/davclient/hpricot_extensions.rb, line 45
def content=(string)
  if(!isCollection?)
    WebDAV.put_string(href,string)
  end
end
property(name) click to toggle source

Get property for resource or collection. Example:

page = WebDAV.find(url)
print page.property("published-date")
# File lib/davclient/hpricot_extensions.rb, line 55
def property(name)

  # TODO: Make list of recognized namespace prefixes configurable

  property = property = self.at(name)
  if(property)then
    returnValue = property.innerText
    return returnValue
  end

  property = property = self.at(name.downcase)
  if(property)then
    return property.innerText
  end

  vrtx_property = self.at("v:" + name)
  if(vrtx_property)then
    return vrtx_property.innerText
  end

  vrtx_property = self.at("v:" + name.downcase)
  if(vrtx_property)then
    return vrtx_property.innerText
  end

  dav_property = self.at("d:" +name)
  if( dav_property)then
    return dav_property.innerText
  end

  dav_property = self.at("d:" +name.downcase)
  if( dav_property)then
    return dav_property.innerText
  end

  return nil
end
proppatch(properties) click to toggle source

Set the items WebDAV properties. Properties must be a string with XML. Example:

find(url) do |item|
   if(item.href =~ /html$/) then
     item.proppatch("<d:getcontenttype>text/html</d:getcontenttype>")
   end
end
# File lib/davclient/hpricot_extensions.rb, line 106
def proppatch(properties)
  WebDAV.proppatch(href, properties)
end