How to get a hyperlink in an XML file? - php

I want to set hyperlink in the image in XML file.
Here is my code of XML file:
<logos>
<logo id="1" name="Abc" path="abc.jpg" x="23" y="4" height="10" width="60"/>
<logo id="2" name="Xya" path="xyz.jpg" x="50" y="`4" height="20" width="40"/>
</logos>
I want to set hyperlink in this image.

XML is a generic data format. It doesn't have any hyperlink capabilities. A specific XML application can (XHTML, for example, has the a element).
If the XML application you are using doesn't include anything to describe hyperlinks, then you need to change it, possibly by importing something from another namespace (such as XLink).
The software that consumes the application will almost certainly have to be updated to add support for the change you make to the language.

I would set an attribute in the node for link_out like:
<logo link_out=""...
Or create a child element to the Logo node if multiple links will ever be in use.
Really hard to understand your need for this.

what XML structure are you following? If you aren't following one, what is stopping you from doing something like:
<logos>
<logo>
<image blah="">
<link blah="">
</logo>
</logos>
Hard to help you when there are a myriad of solutions, but we don't have all the details.

In the XML file, you need to tell it to ignore tags that are intended as html
tags and not tags of the xml structure by enclosing the html using
<![CDATA[ your html ]]>
<urlLink><![CDATA[ Click Here ]]></urlLink>

Related

How to add alt text to an image inserted from PHP

I have an html file with this line:
<div >%%GLOBAL_ProductThumb%%</div>
and live it generates this:
<img width="200px" height="200px" alt="" src="[I removed the URL]">
In a PHP file, I see the variable being assigned on this line
$GLOBALS['ProductThumb'] = ImageThumb200x200($rowimg['imagefile']);
I don't know much about PHP, but how can I add fill the "alt" property with text? In what step/where would this occur? If this were Java I wouldn't have a problem figuring out how to set the property of an object, but I'm not quite sure what's going on here. If the context helps, it's custom shopping cart software designed for our business.
PHP has no standard means to add some HTML attribute to a HTML tag. All you can do is build the HTML code as a string, then printing out the string. Which is something your software does by grabbing some other variables, giving you little direct influence on the generated code.
That said, the only thing you can do is inspecting what exactly all those custom functions are returning. If you are lucky, you find the exact HTML code that will land on the page in the end somewhere. From there, it's just a matter of programmatically searching and replacing before handing the final string further down the line.
A jquery hack can do that for you. If you can penetrate that third party app. You can embed a Jquery code that can take care of it on DOM Ready event.
Example:
<script type="text/javascript">
$(document).ready(function(){
$("img[width='200px'][height='200px']").prop("alt", "Your ALT value");
})
</script>

i want to get data from another website and display it on mine but with my style.css

So my school has this very annoying way to view my rooster.
you have to bypass 5 links to get to my rooster.
this is the link for my class (it updates weekly without changing the link)
https://webuntis.a12.nl/WebUntis/?school=roc%20a12#Timetable?type=1&departmentId=0&id=2147
i want to display the content from that page on my website but with my
own stylesheet.
i don't mean this:
<?php
$homepage = file_get_contents('http://www.example.com/');
echo $homepage;
?>
or an iframe....
I think this can be better done using jquery and ajax. You can get jquery to load the target page, use selectors to strip out what you need, then attach it to your document tree. You should then be able to style it anyway you like.
I would recommend you to use the cURL library: http://www.php.net/manual/en/curl.examples.php
But you have to extract part of the page you want to display, because you will get the whole HTML document.
You'd probably read the whole page into a string variable (using file_get_contents like you mentioned for example) and parse the content, here you have some possibilities:
Regular expressions
Walking the DOM tree (eg. using PHPs DOMDocument classes)
After that, you'd most likely replace all the style="..." or class="..." information with your own.

Return and embed image with pure javascript , like php?

I'm having trouble figuring out if it's possible to embed an html or js document as an image, like so:
<img src="http://blah.com/image.js" />
or
<img src="http://blah.com/image.html" />
The general idea being that when the browser tries to access the file, it would execute the file clientside and get the actual image, and would then embed it as usual. I realize this can be done easily with PHP, but I'm looking for a non-server solution.
Problems being the content type it transfers as is wrong, and more importantly I think this violates every crossdomain and sandbox rule, to which I don't think there's any way around.
As long as the document you are linking to can display the binary data this will work.
Follow this article to solve the binary load with javascript, http://emilsblog.lerch.org/2009/07/javascript-hacks-using-xhr-to-load.html
Then you can also include base64 data in img tags like this
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAIAAABL1vtsAAAYImlDQ1BJQ0MgUHJvZmlsZQAAWAmtWXk4Vd333+fOLtc8z/M8y5x5zpiZiGue47qENBhSoYEkohQyFg1CUkKoSIZCoTQIUSmkDPlt3nrf9/t8n+9/v/M8d5/PWeez11577XX2XntfALjryJGRYShGAMIjqBR7M0NBVzd3QfwYIAA0AAAFiGTf6EgDOzsr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results in actual image data. Perhaps you should consider leaving it blank and then creating a script that generates a data: URI and replaces it into the attribute.

PHP in XML file (or PHP file as XML one)

I have this code (part of bigger script):
flashvars.xmlSource = "datasource.xml";
datasource.xml looks like:
<?xml version="1.0" encoding="utf-8"?>
<Object>
<Contents>
<Source="address" Title="title"></Source>
<Description><h1>New hot Features</h1><p>The all new Piecemaker comes with lots of new features, making it even more slick.</p><p>Just to mention a few - you can now specify unlimited transition styles, include your own SWF and Video files, add hyperlinks to images and info texts with all special characters.</p><p>We also impoved the navigation and the animation with animated shadows and pixel-perfect transitions.</p></Description>
(...)
</Contents>
</Object>
I want to generate datasource.xml dynamically using foreach loop.
I've just changed the file extension to .php but this is not that easy ;)
Any ideas?
Funny or not, but try this one:
leave your file extension to be "xml"
where you wrote (...) write <? PHP CODE HERE ?>
So handle it as if it would be some html file. What I mean is:
<?xml version="1.0" encoding="utf-8"?>
<Object>
<Contents>
<Source="address" Title="title"></Source>
<Description><h1>New hot Features</h1><p>The all new Piecemaker comes with lots of new features, making it even more slick.</p><p>Just to mention a few - you can now specify unlimited transition styles, include your own SWF and Video files, add hyperlinks to images and info texts with all special characters.</p><p>We also impoved the navigation and the animation with animated shadows and pixel-perfect transitions.</p></Description>
<? create php loop here ?>
</Contents>
</Object>
Also note
this line
<Source="address" Title="title"></Source>
might be wrong (you assigned some value to the tagname), try
<Source name="address" Title="title"></Source>
or something like that.
As I see generating xml file with php could be done in this way - for example you'll create file datasource.xml which will be not a static xml file but xml with php code included with contents like
<?php //php code to generate any xml code as Text
// it can be whatever you need to generate
// for example
$content="<h1>New hot Features</h1><p>The all new Piecemaker comes with lots of new features, making it even more slick.</p><p>Just to mention a few - you can now specify unlimited transition styles, include your own SWF and Video files, add hyperlinks to images and info texts with all special characters.</p><p>We also impoved the navigation and the animation with animated shadows and pixel-perfect transitions.</p>";
$output="<Description>".$content."</Description>";
header('Content-type: application/xml');// this is most important php command which says that all output text is XML it must be called before any line of xml will be printed.
// So you need at first generate XML as text then call this command and echo contents of your xml file.
?>
<?xml version="1.0" encoding="utf-8"?>
<Object>
<Contents>
<Source name="address" Title="title"></Source>
<? echo $output; ?>
</Contents>
</Object>
In order to allow php to execute php code inside XML file we need to add some directives to apache host configuration file. In my case I added
<IfModule mod_php5.c>
<FilesMatch "\.xml$">
SetHandler application/x-httpd-php
</FilesMatch>
inside my virtual host configuration file, or you can place this command inside .htaccess file in your directory if Override of this param is allowed in your host configuration.
And about xml- to make sure it's ok you can use http://validator.w3.org/ or http://www.w3schools.com/xml/xml_validator.asp to validate xml generated by your script.
Does this XML need to be a stored file somewhere on the server, or can you just pass it a string formatted like the XML you mentioned. You could write a function that generates the XML you're looking for and returns it, based on input and then call that like
function generateXML($input){
$xml = '<?xml version="1.0" encoding="utf-8"?><Object><Contents>
<Source="address" Title="title"></Source><Whateverelse>' . $input;
$xml .= '</Whateverelse></Contents></Object>';
return $xml;}
flashvars.xmlSource = generateXML("This is whatever else");
If you need to actually generate and store a well formed XML document, or if your XML is fairly complex and you need to generate an object rather than just using a string, you can utilize one of the PHP libraries to do this like http://php.net/manual/en/book.simplexml.php

Displaying an XML file with XSL within an existing webpage

I'm trying to get an html page to display an XML file formatted with an XSL stylesheet. Whatever examples I see are either displaying it in a new page, with the XSL stylesheet taking care of the tags, but no examples where I can clearly see it being displayed as part of an existing webpage...
I'm using a PHP script to generate the HTML. And the XML data is being generated by another PHP function (not under my control). The XSL file is uploaded on the server and stored at: /xsl/1234567890.xsl
Here's what the php outputs:
<html>
...
<body>
...
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/xsl/1234567890.xsl"?>
...
<xml tags>
...
What am I doing wrong?
Two ways to transform the XML:
1 browser
Most browsers implement XSLT processors. You could use:
<iframe src="xml-source.xml"/>
The users will have to make three requests (page, xml, xsl) and unless you want inline scrollbars you'll need some Javascript to resize the iframe.
2 server
You can run a XSLT processor on the server side and return the transformed XML. There are many ways to do this, here is one in PHP. With caching you shouldn't run into any performance problems and also support browsers without internal XSLT processors (e.g. mobile devices).

Categories