XML::LibXML findnodes Invalid Expression

D

douglasforrest

I have a well-formed UTF-16 document which looks something like this:

<?xml version="1.0" encoding="UTF-16"?>
<alerts>
<alert id="15670">
<name>Test</name>
</alert>
<alert id="15671">
<name>Another Test</name>
</alert>
</alerts>

After parsing using XML::LibXML, findnodes using "//alert" from the
root element

@nodes = $root->findnodes('//alert'))

produces an XPath Invalid expression error.

Findnodes using "/alert" does not trigger an error but produces 0
nodes.

Applying an XSLT stylesheet via XML::LibXSLT using "//alert" runs fine
and produces the expected 2 results.

The stylesheet looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="//alert">
<xsl:value-of select="name"/><br/>
</xsl:template>
</xsl:stylesheet>

Any suggestions would be much appreciated.
 
D

douglasforrest

Solved (or work-around) -- converted document from UTF-16 to UTF-8 and
changed the encoding declaration accordingly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top