Solved

XSLL Transformation on PHP4

Posted on 2006-07-23
5
294 Views
Last Modified: 2006-11-18
I started with some advice from this question i found:
http://www.experts-exchange.com/Web/Web_Languages/PHP/Q_20272154.html?query=xsl&topics=103&showAll=true

Got it working fine with xml and xsl in outside files, but the problem is that my xml is not in a file, it is local memory.
Here is the code i am trying:

      $xml = '<RESULT><ROW id="1">1</ROW><ROW id="2">2</ROW><ROW id="3">3</ROW></RESULT>';

      $xh = xslt_create();
      
      $args = array( "xmldata" => $xml);
      
      xslt_process($xh, 'arg:/xmldata', 'test.xsl', $result, $args);
      if ($result) {
            print $result;
      } else {
            print "  the \$result variable the reason is that " . xslt_error($xh) .
            print " and the error code is " . xslt_errno($xh);
      }
      xslt_free($xh);

and this is the error i get:
"and the error code is 0  the $result variable the reason is that 1"

Thanks for the help...
0
Comment
Question by:qwertq
  • 3
  • 2
5 Comments
 
LVL 29

Expert Comment

by:TeRReF
ID: 17164040
Try this:
$xml = '<RESULT><ROW id="1">1</ROW><ROW id="2">2</ROW><ROW id="3">3</ROW></RESULT>';
$xml = domxml_open_mem($xml)
0
 

Author Comment

by:qwertq
ID: 17164044
Fatal error: Call to undefined function: domxml_open_mem() in
0
 
LVL 29

Accepted Solution

by:
TeRReF earned 150 total points
ID: 17164064
Try to change this line:
xslt_process($xh, 'arg:/xmldata', 'test.xsl', $result, $args);
to
$result = xslt_process($xh, 'arg:/xmldata', 'test.xsl', NULL, $args);
0
 

Author Comment

by:qwertq
ID: 17164068
thanks that worked....

what is that NULLed value for then? the post i linked above said it was result, so i was using it for that.
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17164125
It is the result, but it's a container, that's why the
if($result) didn't work.
If you use the NULL there, the function returns a string.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question