Solved

XSLL Transformation on PHP4

Posted on 2006-07-23
5
290 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
Comment Utility
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
Comment Utility
Fatal error: Call to undefined function: domxml_open_mem() in
0
 
LVL 29

Accepted Solution

by:
TeRReF earned 150 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now