Class: XML::XPATH
- Inherits:
-
Object
- Object
- XML::XPATH
- Defined in:
- ext/xpath/xpath.c
Constant Summary collapse
- XML_ELEMENT_NODE =
INT2NUM( 1 )
- XML_ATTRIBUTE_NODE =
INT2NUM( 2 )
- XML_TEXT_NODE =
INT2NUM( 3 )
- XML_CDATA_SECTION_NODE =
INT2NUM( 4 )
- XML_ENTITY_REF_NODE =
INT2NUM( 5 )
- XML_ENTITY_NODE =
INT2NUM( 6 )
- XML_PI_NODE =
INT2NUM( 7 )
- XML_COMMENT_NODE =
INT2NUM( 8 )
- XML_DOCUMENT_NODE =
INT2NUM( 9 )
- XML_DOCUMENT_TYPE_NODE =
INT2NUM( 10 )
- XML_DOCUMENT_FRAG_NODE =
INT2NUM( 11 )
- XML_NOTATION_NODE =
INT2NUM( 12 )
- XML_HTML_DOCUMENT_NODE =
INT2NUM( 13 )
- XML_DTD_NODE =
INT2NUM( 14 )
- XML_ELEMENT_DECL =
INT2NUM( 15 )
- XML_ATTRIBUTE_DECL =
INT2NUM( 16 )
- XML_ENTITY_DECL =
INT2NUM( 17 )
- XML_NAMESPACE_DECL =
INT2NUM( 18 )
- XML_XINCLUDE_START =
INT2NUM( 19 )
- XML_XINCLUDE_END =
INT2NUM( 20 )
- XML_DOCB_DOCUMENT_NODE =
INT2NUM( 21 )
- RUBY_XPATH_VERSION =
rb_str_new2( RUBY_XPATH_VERSION )
Class Method Summary collapse
-
.new ⇒ Object
o = XML::XPATH.new().
Instance Method Summary collapse
- #attrs ⇒ Object
- #content ⇒ Object
-
#each ⇒ Object
——————————————————————————-.
-
#execute(xpathExp) ⇒ Object
o.execute( XPathExp ).
- #first ⇒ Object
- #last ⇒ Object
-
#name ⇒ Object
——————————————————————————-.
- #next ⇒ Object
-
#ns=(ns_hash) ⇒ Object
o.ns={ … }.
- #path ⇒ Object
- #prev ⇒ Object
-
#to_a ⇒ Object
a = o.to_a.
- #type ⇒ Object
-
#xml ⇒ Object
xmlData = o.xml.
-
#xml=(xml_doc_str) ⇒ Object
o.xml = “<…>”.
-
#xmlfile=(xml_doc_file) ⇒ Object
o.xmlfile=“file.xml”.
Class Method Details
.new ⇒ Object
o = XML::XPATH.new()
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 |
# File 'ext/xpath/xpath.c', line 467
VALUE ruby_xpath_new( VALUE class ) {
RbTxpath *pRbTxpath;
pRbTxpath = (RbTxpath *)malloc(sizeof(RbTxpath));
if( pRbTxpath == NULL )
rb_raise(rb_eNoMemError, "No memory left for XPATH struct");
pRbTxpath->iXmlType = RUBY_XPATH_XMLSRC_TYPE_NULL;
pRbTxpath->xXmlData = Qnil;
pRbTxpath->hxNS = Qnil;
pRbTxpath->rbResult = Qnil;
pRbTxpath->iCurrentNode = 0;
pRbTxpath->iNbNodes = 0;
return( Data_Wrap_Struct( class, ruby_xpath_mark, ruby_xpath_free, pRbTxpath ) );
}
|
Instance Method Details
#attrs ⇒ Object
435 436 437 |
# File 'ext/xpath/xpath.c', line 435 VALUE ruby_xpath_xml_attrs( VALUE self ) { return( get_node_element( self, "attrs" ) ); } |
#content ⇒ Object
443 444 445 |
# File 'ext/xpath/xpath.c', line 443 VALUE ruby_xpath_xml_content( VALUE self ) { return( get_node_element( self, "content" ) ); } |
#each ⇒ Object
363 364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'ext/xpath/xpath.c', line 363
VALUE ruby_xpath_xml_each( VALUE self ) {
RbTxpath *pRbTxpath;
Data_Get_Struct( self, RbTxpath, pRbTxpath );
int iCpt;
if (rb_block_given_p()) {
for( iCpt = 0; iCpt < pRbTxpath->iNbNodes; iCpt++ ) {
VALUE rbNode = rb_ary_entry( pRbTxpath->rbResult, iCpt );
rb_yield( rbNode );
}
}
return( Qnil );
}
|
#execute(xpathExp) ⇒ Object
o.execute( XPathExp )
341 342 343 344 345 346 347 348 349 350 351 |
# File 'ext/xpath/xpath.c', line 341
VALUE ruby_xpath_xml_execute( VALUE self, VALUE xpathExp ) {
int RCod = -1;
RbTxpath *pRbTxpath;
Check_Type( xpathExp, T_STRING );
Data_Get_Struct( self, RbTxpath, pRbTxpath );
RCod = parse( STR2CSTR( pRbTxpath->xXmlData ), pRbTxpath->iXmlType, BAD_CAST STR2CSTR( xpathExp ), pRbTxpath );
return( INT2NUM( RCod ) );
}
|
#first ⇒ Object
377 378 379 380 381 382 383 384 385 386 387 388 |
# File 'ext/xpath/xpath.c', line 377
VALUE ruby_xpath_xml_first( VALUE self ) {
RbTxpath *pRbTxpath;
Data_Get_Struct( self, RbTxpath, pRbTxpath );
int RCod = 0;
if( pRbTxpath->iNbNodes > 0 ) {
pRbTxpath->iCurrentNode = 0;
RCod = 1;
}
return( INT2NUM( RCod ) );
}
|
#last ⇒ Object
390 391 392 393 394 395 396 397 398 399 400 401 |
# File 'ext/xpath/xpath.c', line 390
VALUE ruby_xpath_xml_last( VALUE self ) {
RbTxpath *pRbTxpath;
Data_Get_Struct( self, RbTxpath, pRbTxpath );
int RCod = 0;
if( pRbTxpath->iNbNodes > 0 ) {
pRbTxpath->iCurrentNode = pRbTxpath->iNbNodes - 1;
RCod = pRbTxpath->iNbNodes;
}
return( INT2NUM( RCod ) );
}
|
#name ⇒ Object
431 432 433 |
# File 'ext/xpath/xpath.c', line 431 VALUE ruby_xpath_xml_name( VALUE self ) { return( get_node_element( self, "name" ) ); } |
#next ⇒ Object
403 404 405 406 407 408 409 410 411 412 413 414 |
# File 'ext/xpath/xpath.c', line 403
VALUE ruby_xpath_xml_next( VALUE self ) {
RbTxpath *pRbTxpath;
Data_Get_Struct( self, RbTxpath, pRbTxpath );
int RCod = 0;
if( pRbTxpath->iCurrentNode + 1 < pRbTxpath->iNbNodes ) {
pRbTxpath->iCurrentNode += 1;
RCod = pRbTxpath->iCurrentNode + 1;
}
return( INT2NUM( RCod ) );
}
|
#ns=(ns_hash) ⇒ Object
o.ns={ … }
328 329 330 331 332 333 334 335 336 |
# File 'ext/xpath/xpath.c', line 328
VALUE ruby_xpath_xml_ns_set( VALUE self, VALUE ns_hash ) {
RbTxpath *pRbTxpath;
Check_Type( ns_hash, T_HASH );
Data_Get_Struct( self, RbTxpath, pRbTxpath );
pRbTxpath->hxNS = ns_hash;
return( Qnil );
}
|
#path ⇒ Object
447 448 449 |
# File 'ext/xpath/xpath.c', line 447 VALUE ruby_xpath_xml_path( VALUE self ) { return( get_node_element( self, "path" ) ); } |
#prev ⇒ Object
416 417 418 419 420 421 422 423 424 425 426 427 |
# File 'ext/xpath/xpath.c', line 416
VALUE ruby_xpath_xml_prev( VALUE self ) {
RbTxpath *pRbTxpath;
Data_Get_Struct( self, RbTxpath, pRbTxpath );
int RCod = 0;
if( pRbTxpath->iCurrentNode - 1 >= 0 ) {
pRbTxpath->iCurrentNode -= 1;
RCod = pRbTxpath->iCurrentNode + 1;
}
return( INT2NUM( RCod ) );
}
|
#to_a ⇒ Object
a = o.to_a
354 355 356 357 358 359 |
# File 'ext/xpath/xpath.c', line 354
VALUE ruby_xpath_xml_to_a( VALUE self ) {
RbTxpath *pRbTxpath;
Data_Get_Struct( self, RbTxpath, pRbTxpath );
return( pRbTxpath->rbResult );
}
|
#type ⇒ Object
439 440 441 |
# File 'ext/xpath/xpath.c', line 439 VALUE ruby_xpath_xml_type( VALUE self ) { return( get_node_element( self, "type" ) ); } |
#xml ⇒ Object
xmlData = o.xml
299 300 301 302 303 304 305 306 307 |
# File 'ext/xpath/xpath.c', line 299
VALUE ruby_xpath_xml_str_get( VALUE self ) {
RbTxpath *pRbTxpath;
Data_Get_Struct( self, RbTxpath, pRbTxpath );
if( pRbTxpath->iXmlType == RUBY_XPATH_XMLSRC_TYPE_NULL )
return( Qnil );
else
return( (VALUE)pRbTxpath->xXmlData );
}
|
#xml=(xml_doc_str) ⇒ Object
o.xml = “<…>”
310 311 312 313 314 315 316 317 318 319 |
# File 'ext/xpath/xpath.c', line 310
VALUE ruby_xpath_xml_str_set( VALUE self, VALUE xml_doc_str ) {
RbTxpath *pRbTxpath;
Data_Get_Struct( self, RbTxpath, pRbTxpath );
pRbTxpath->iXmlType = RUBY_XPATH_XMLSRC_TYPE_STR;
pRbTxpath->xXmlData = object_to_string( xml_doc_str );
return( xml_doc_str );
}
|
#xmlfile=(xml_doc_file) ⇒ Object
o.xmlfile=“file.xml”
322 323 324 325 |
# File 'ext/xpath/xpath.c', line 322
VALUE ruby_xpath_xml_file_set( VALUE self, VALUE xml_doc_file ) {
rb_warn( "XML::XSLT#xmlfile=<file> is deprecated. Please use XML::XSLT#xml=<file> !" );
return( ruby_xpath_xml_str_set( self, xml_doc_file ) );
}
|