HI, I am parsing an XML file using LibXML in Perl. The problem that I have is the ending characters (whitespace) is treated as a text node. For instance, given an input like the following
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE books [
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT book (title, author, year, price)>
<!ELEMENT books (book*)>
]>
<books>
<book>
<title>Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
</books>
The parser thinks that the number of child of node "books" is 3, they are:
- text node (containing the char between
<books>
and<book>
) - element node of
<book>
- text node (containing the char between
</book>
and</books>
)
Question is how do I tell LibXML to ignore whitespaces? I tried with no_blanks (that is $parser = XML::LibXML->new(no_blanks => 1) when construction the parser) but it seems that it has no effect.
Thanks in advance