Skip to content

Instantly share code, notes, and snippets.

@ilake
Created October 13, 2016 15:37
Show Gist options
  • Save ilake/995ccfacf452ce10984d947c1dcab4ec to your computer and use it in GitHub Desktop.
Save ilake/995ccfacf452ce10984d947c1dcab4ec to your computer and use it in GitHub Desktop.
# find node name is gd:email and attribute rel value contains work wording
node = doc.xpath("//*[name()='gd:email'][contains(@rel, 'work')]").first
# change email address attribute value
node.attributes["address"].value = value[:address]
# change node content <node>{content is here}</node>
node.content = value
# remove all nodes that name is gd:phoneNumber
doc.xpath("//*[name()='gd:phoneNumber']").remove
# add node
doc.children.children.last.add_next_sibling(
%Q|<gd:phoneNumber #{attr} primary="#{!!phone_value[:primary]}">#{phone_value[:number]}</gd:phoneNumber>|
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment