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
| sergio@Ystad:~/Programming/projects/nokogiri/lib$ irb1.8 -rubygems -rnokogiri | |
| irb(main):001:0> fruits = Nokogiri::XML(<<-eoxml) | |
| irb(main):002:1" <Fruit xmlns='http://www.fruits.org'> | |
| irb(main):003:1" </Fruit> | |
| irb(main):004:1" eoxml | |
| => <?xml version="1.0"?> | |
| <Fruit xmlns="http://www.fruits.org"> | |
| </Fruit> | |
| irb(main):005:0> apple = fruits.fragment('<Apple/>') |
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
| // C code | |
| // the child was a text node that was coalesced. we need to have the object | |
| // point at SOMETHING, or we'll totally bomb out. | |
| if (reparented != node) { | |
| DATA_PTR(node_obj) = reparented ; | |
| } |
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
| /** | |
| * xmlGetNodePath: | |
| * @node: a node | |
| * | |
| * Build a structure based Path for the given node | |
| * | |
| * Returns the new path or NULL in case of error. The caller must free | |
| * the returned string | |
| */ | |
| xmlChar * |
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 test_document_has_errors | |
| doc = Nokogiri::XML(<<-eoxml) | |
| <foo><bar></foo> | |
| eoxml | |
| assert doc.errors.length > 0 | |
| doc.errors.each do |error| | |
| assert_match error.message, error.inspect | |
| assert_match error.message, error.to_s | |
| end | |
| end |
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
| [alias] | |
| st = status | |
| ci = commit | |
| co = checkout | |
| svnup = svn fetch | |
| sup = svn fetch | |
| svnci = svn dcommit | |
| sci = svn dcommit | |
| up = pull --rebase | |
| sreb = svn rebase |
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
| <?xml version="1.0" ?> | |
| <hi> | |
| <Im> | |
| a not-well-formed XML | |
| </hi> |
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 test_node_added_to_root_should_get_namespace | |
| fruits = Nokogiri::XML(<<-eoxml) | |
| <Fruit xmlns='http://www.fruits.org'> | |
| </Fruit> | |
| eoxml | |
| apple = fruits.fragment('<Apple/>') | |
| fruits << apple | |
| assert_equal 1, fruits.xpath('//xmlns:Apple').length | |
| end |
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 test_singleton_methods | |
| assert node_set = @xml.search('//name') | |
| assert node_set.length > 0 | |
| node = node_set.first | |
| def node.test | |
| 'test' | |
| end | |
| assert node_set = @xml.search('//name') | |
| assert_equal 'test', node_set.first.test | |
| end |
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
| irb(main):003:0> DP = Java::OrgCybernekoHtmlParsers::DOMParser | |
| => Java::OrgCybernekoHtmlParsers::DOMParser | |
| irb(main):004:0> dp = DP.new | |
| => #<Java::OrgCybernekoHtmlParsers::DOMParser:0x69e94001> | |
| irb(main):005:0> dp.parse "<html><head></head><body></body></html>".to_java_string | |
| NativeException: java.net.MalformedURLException: no protocol: <html><head></head><body></body></html> | |
| from java/net/URL.java:583:in `<init>' | |
| from java/net/URL.java:480:in `<init>' | |
| from java/net/URL.java:429:in `<init>' | |
| from org/cyberneko/html/HTMLScanner.java:862:in `setInputSource' |
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
| if Nokogiri.uses_libxml? | |
| def test_namespace_without_an_href_on_html_node | |
| # because microsoft word's HTML formatting does this. ick. | |
| xml = Nokogiri::HTML.parse <<-EOF | |
| <div><o:p>foo</o:p></div> | |
| EOF | |
| assert_not_nil(node = xml.at('p')) | |
| assert_equal 1, node.namespaces.keys.size |