View Full Version : Need help....
kenshn111
05-11-2010, 08:54 AM
I'm thinking of something and wonder if it exists...
Making an info.xml > use a script to get the info > display it on a site or something....
like...
inside the info.xml
(separated by commas)
|rank|name|datereg|image|
#00001,Maaku,05/11/2010,http://www.google.com/images/srpr/nav_logo13.png
----
and the script would like.. get all the information....
<image><name>
<rank><datereg>
is it possible to do something like that?
of course.
There have been a rash of threads on the forums regarding xml; look through some of them. If you're using ph
p, I'd recommend starting here (http://us3.php.net/manual/en/book.simplexml.php).
Do you have a good grasp on xml yet? For example, your example above would be something like:
<?xml version="1.0" encoding='UTF-8'?>
<xmlroot>
<record>
<id>0001</id>
<name>Maaku</name>
<datereg>05-10-2010</datereg>
<image>http://www.google.com/images/srpr/nav_logo13.png</image>
</record>
<record>
...more records, etc...
</record>
</xmlroot>
kenshn111
05-11-2010, 03:33 PM
Oh, I forgot to add, is that possible doing in Javascript, I googled it up and found some but for some reason it doesn't work in Mozilla Firefox D:
and I also found XML parsing using PHP (output xml using php)
but there's always an error D:
Oh, I forgot to add, is that possible doing in Javascript, I googled it up and found some but for some reason it doesn't work in Mozilla Firefox D:
I'm sure it can be, but that's not my expertise. Maybe you could find some help in the javascript forum.
...and I also found XML parsing using PHP (output xml using php)
but there's always an error D:
Not always :D. What sort of errors are you getting?
djr33
05-12-2010, 12:55 AM
Regarding Javascript, it may be possible, but it would be less reliable and almost inevitably harder to setup. PHP is designed for this kind of thing; Javascript is definitely not.
kenshn111
05-12-2010, 12:56 AM
If possible, can someone code it for me?
djr33
05-12-2010, 12:57 AM
Try google to see what you find. I think it would be a lot of work to code. It's not something I can do (but my specialty isn't Javascript).
You could look for paid help if you can't find someone to do it for free.
kenshn111
05-12-2010, 12:58 AM
Oh.. okay I'll look harder this time(for some reason, I can't find what I've found yesterday! D: )
I can do this for you (via php), but not for free. Please contact me here (http://www.custom-anything.com/contactme.php) if you're interested.
If you'd like to try it yourself, post what you have and we'd be happy to help you figure it out.
Oh.. okay I'll look harder this time(for some reason, I can't find what I've found yesterday! D: ) look in your browser history :)
kenshn111
05-12-2010, 02:34 AM
So.... I tried something...
XML
<books>
<book>
<author>Jack Herrington</author>
<title>PHP Hacks</title>
<publisher>O'Reilly</publisher>
</book>
<book>
<author>Jack Herrington</author>
<title>Podcasting Hacks</title>
<publisher>O'Reilly</publisher>
</book>
</books>
PHP
<?php
$doc = new DOMDocument();
$doc->load( 'abc.xml' );
$books = $doc->getElementsByTagName( "book" );
foreach( $books as $book )
{
$authors = $book->getElementsByTagName( "author" );
$author = $authors->item(0)->nodeValue;
$publishers = $book->getElementsByTagName( "publisher" );
$publisher = $publishers->item(0)->nodeValue;
$titles = $book->getElementsByTagName( "title" );
$title = $titles->item(0)->nodeValue;
echo "$title - $author - $publisher\n";
}
?>
And I get this error : Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /~/www/transparent.agilityhoster.com/test.php on line 9
Links : http://transparent.agilityhoster.com/test.php
You're using (parenthesis) instead of [square brackets] for your indices. Try $authors->item[0]->nodeValue (et al.) instead.
kenshn111
05-12-2010, 06:37 AM
man... another fatal error : Fatal error: Cannot instantiate non-existent class: domdocument in /~/www/transparent.agilityhoster.com/test.php on line 2
wait. imma check...
<?php
$doc = new DOMDocument();
$doc->load( 'abc.xml' );
$books = $doc->getElementsByTagName( "book" );
foreach( $books as $book )
{
$authors = $book->getElementsByTagName( "author" );
$author = $authors->item[0]->nodeValue;
$publishers = $book->getElementsByTagName( "publisher" );
$publisher = $publishers->item[0]->nodeValue;
$titles = $book->getElementsByTagName( "title" );
$title = $titles->item[0]->nodeValue;
echo "$title - $author - $publisher\n";
}
?>
where are you testing this? does your host support php5 and libxml? DOMdocument can also be disabled deliberately by your host; check with them to see if it is enabled.
kenshn111
05-13-2010, 08:25 AM
Sorry for the late reply, they only have PHP 4.2.3 so I went to another free web hosting site :)
that explains it.
you might look into the simpleXML (http://us.php.net/manual/en/book.simplexml.php) class as well; some aspects are much easier.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.