Solved

XSLL Transformation on PHP4

Posted on 2006-07-23
5
295 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
$_SERVER Variable question 31 56
Inserting results of While loop to sql server 5 38
Make check boxes work 8 47
How do I fix this error with quotation marks? 4 27
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

730 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