Created
May 9, 2009 10:50
-
-
Save ravicious/109219 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mam plik blist.xml. Udostępniłem pewną część jego zawartości. | |
Moim celem jest wycięcie całego drzewa "contact", jeśli contact/buddy/name zawiera "gg.jabbim.pl". | |
Próbowałem już czegoś takiego, jak w pliku moje_rozwiazanie.rb (jest to też część większego skryptu), ale niestety, to rozwiązanie nie działa prawidłowo, w zasadzie to nie robi nic. Nie działa, ponieważ klasa contact to Hpricot::Elem, a nie Hpricot::Elements, dla którego metoda remove zadziała. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<purple version='1.0'> | |
<blist> | |
<group name='blah blah'> | |
<contact> | |
<buddy account='ravicious@jabbim.pl/1337' proto='prpl-jabber'> | |
<name>66666666@gg.jabbim.pl</name> | |
<alias>Wuja Lucyfer</alias> | |
<setting name='last_seen' type='int'>1241808774</setting> | |
</buddy> | |
</contact> | |
<contact> | |
<buddy account='ravicious@jabbim.pl/1337' proto='prpl-jabber'> | |
<name>tybecik@takiwypasionyserwerjabbera.ch</name> | |
<alias>Wuja Chuia-Wart</alias> | |
<setting name='last_seen' type='int'>1241793827</setting> | |
</buddy> | |
<setting name='gtk-mute-sound' type='bool'>0</setting> | |
</contact> | |
</group> | |
</blist> | |
</purple> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clean_roster | |
@doc.search("//contact").each do |contact| | |
contact.remove if contact.search("//buddy/name").inner_html.include? "gg.jabbim.pl" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment