List Info

Thread: RE: perl-ish way to deal with footnotes in an XML document




RE: perl-ish way to deal with footnotes in an XML document
country flaguser name
United States
2007-07-19 14:34:56
--- "Thomas, Mark - BLS CTR" <Thomas.Markbls.gov>
wrote:

> > That's good to know. Do you have any suggestions
> how exactly I might
> > go
> > about it, then?
> > 
> > I tried this with XML::LibXML:
> > 
> > my $children = $seg->findnodes('child:');
> >     foreach my $child ($children->get_nodelist)
{
> >         print $child->textContent ;
> >         my $name = $child->nodeName;
> >         print "$name n";
> > }
> 
> I'm pretty sure * returns only elements, not text
> nodes. Try this
> instead:
> 
> foreach my $child ($seg->childNodes) {
>     my $name = $child->nodeName;
>     print "$namen";
> }
> 
> - Mark.


I've used nodeType() with childNodes() in the past but
I can't find the list of (numeric) node types right
now.


foreach my $segChild ( $seg->childNodes() ) {
    if ( $segChild->nodeType() == 3 ) {
        print $segChild->toString();
    } elsif ( $segChild->nodeType() == 1 ) {

    }
}




       
____________________________________________________________
________________________
Be a better Globetrotter. Get better travel answers from
someone who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=3965454
69
_______________________________________________
Perl-XML mailing list
Perl-XMLlistserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs

Re: perl-ish way to deal with footnotes in an XML document
country flaguser name
Czech Republic
2007-07-19 15:28:19
On Thursday 19 July 2007, Joshua Santelli wrote:
> --- "Thomas, Mark - BLS CTR"
<Thomas.Markbls.gov>
>
> wrote:
> > > That's good to know. Do you have any
suggestions
> >
> > how exactly I might
> >
> > > go
> > > about it, then?
> > >
> > > I tried this with XML::LibXML:
> > >
> > > my $children = $seg->findnodes('child:');
> > >     foreach my $child
($children->get_nodelist) {
> > >         print $child->textContent ;
> > >         my $name = $child->nodeName;
> > >         print "$name n";
> > > }
> >
> > I'm pretty sure * returns only elements, not text
> > nodes. Try this
> > instead:
> >
> > foreach my $child ($seg->childNodes) {
> >     my $name = $child->nodeName;
> >     print "$namen";
> > }
> >
> > - Mark.
>
> I've used nodeType() with childNodes() in the past but
> I can't find the list of (numeric) node types right
> now.

There are constants predefined for the node types in
XML::LibXML::Common.
By default, XML::LibXML exports libxml-style contsants, that
are of the form 
XML_*_NODE, where * is ELEMENT, ATTRIBUTE, TEXT, COMMENT,
PI, DOCUMENT, etc.

This is rather badly documented, I admit.
-- Petr




_______________________________________________
Perl-XML mailing list
Perl-XMLlistserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )