Forum Moderators: coopster

Message Too Old, No Replies

xpath not working

is it a config issue?

         

FourDegreez

7:28 pm on Jan 9, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Trying to work with XML, first I attempted to use SimpleXMLElement. The xpath function was returning nothing but empty arrays no matter what I tried. Then I tried to transform the XML using XSLT. Any attempt to use an xpath expression in the XSL also did not work!

I did verify that the XML and my approach were kosher. Applying this XSL worked as expected and ran through the whole XML document:

<xsl:template match="node()">
  <xsl:element name="element">
    <xsl:attribute name="name">
      <xsl:value-of select="name(.)"/>
    </xsl:attribute>
    <xsl:apply-templates/>
  </xsl:element>
</xsl:template>

It's just that if I were to do something like <xsl:value-of select="/el1/el2/el3"/> it doesn't work, even if I've triple-checked that those elements are present.

For what it's worth, php_info says "XPath Support" is "enabled". Any ideas?

FourDegreez

5:21 pm on Jan 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maybe there are some hiccups/quirks with xpath in PHP? Anything to be mindful of? I'm trying to work with the XML of Amazon's API.