Permalink
Browse files

Added the lineno (line number) property to the xml_tree_node

object, so you can get the line where the tag was declared.


git-svn-id: http://svn.php.net/repository/pear/packages/XML_Tree/trunk@140031 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent be90041 commit 0615a76ad1d0173f008c93101f95d83ee0b1d6eb @tvvcox tvvcox committed Sep 10, 2003
Showing with 8 additions and 6 deletions.
  1. +6 −5 Tree.php
  2. +2 −1 Tree/Node.php
View
@@ -118,9 +118,9 @@ function &getRoot()
* @return object XML_Tree_Node Reference to the newly created root node
* @access public
*/
- function &addRoot($name, $content = '', $attributes = array())
+ function &addRoot($name, $content = '', $attributes = array(), $lineno)
{
- $this->root = new XML_Tree_Node($name, $content, $attributes);
+ $this->root = new XML_Tree_Node($name, $content, $attributes, $lineno);
return $this->root;
}
@@ -277,19 +277,20 @@ function &getTreeFromString($str)
*/
function startHandler($xp, $elem, &$attribs)
{
+ $lineno = xml_get_current_line_number($xp);
// root elem
if (!isset($this->i)) {
- $this->obj1 =& $this->add_root($elem, null, $attribs);
+ $this->obj1 =& $this->add_root($elem, null, $attribs, $lineno);
$this->i = 2;
} else {
// mixed contents
if (!empty($this->cdata)) {
$parent_id = 'obj' . ($this->i - 1);
$parent =& $this->$parent_id;
- $parent->children[] = &new XML_Tree_Node(null, $this->cdata);
+ $parent->children[] = &new XML_Tree_Node(null, $this->cdata, null, $lineno);
}
$obj_id = 'obj' . $this->i++;
- $this->$obj_id = &new XML_Tree_Node($elem, null, $attribs);
+ $this->$obj_id = &new XML_Tree_Node($elem, null, $attribs, $lineno);
}
$this->cdata = null;
return null;
View
@@ -64,12 +64,13 @@ class XML_Tree_Node {
* @param string content Node content (text)
* @param array attributes Attribute-hash for the node
*/
- function XML_Tree_Node($name, $content = '', $attributes = array())
+ function XML_Tree_Node($name, $content = '', $attributes = array(), $lineno)
{
$this->name = $name;
$this->setContent($content);
$this->attributes = $attributes;
$this->children = array();
+ $this->lineno = $lineno;
}
/**

0 comments on commit 0615a76

Please sign in to comment.