[prev in list] [next in list] [prev in thread] [next in thread]
List: perl-xml
Subject: RE: get node content with tags
From: "Thomas, Mark - BLS CTR" <Thomas.Mark () bls ! gov>
Date: 2004-05-26 13:35:15
Message-ID: F483FBEE45D09F49903D169A6E0073240581ACCB () psbmail1 ! psb ! bls ! gov
[Download RAW message or body]
> But, with $node->toString I get the whole node:
>
> <node>Text with <em>XHML</em> tags</node>
>
> and not just the content:
>
> Text with <em>XHML</em> tags
Oops, I must have missed that. There are a couple of ways to do it, one of
which Andrew has already replied with:
$node_content .= $_->toString for $node->childNodes;
Another way is to modify the Xpath you are using to retrieve the node to
instead return childnodes, i.e.
$node_content .= $_->toString for
$doc->findnodes('/somepath/node/node()');
This could save you a step depending on whether you need the parent.
What would be _really_ nice is a toString() method for a nodelist itself.
Then you could do this:
$doc->findnodes('/somepath/node/node()')->toString;
I could use that a lot. Currently nodelists have only to_literal() which
returns the string_value() of each node, which is not the same as
toString().
--
Mark Thomas Thomas.Mark@bls.gov
Internet Systems Architect User Technology Associates, Inc.
$_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;;
_______________________________________________
Perl-XML mailing list
Perl-XML@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic