?
Solved

XSLL Transformation on PHP4

Posted on 2006-07-23
5
Medium Priority
?
299 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 600 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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

762 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