Simple question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Simple question

Post by ol4pr0 »

simple , or should be however i dont know whats wrong lol

just a quick example of what i wrote.. not the same just the same thingies..

[Admin Edit: added for clarity - please use them to make your PHP code easier to read.][/b]

Code: Select all

<?
header('Content-Type: text/xml');
print '<?xml version="1.0"?>'. "\n";
print "<headtag>\n";

$headtag = array(array('firstag' => 'eerste',
		   'secotag' => 'tweede',
		   '3thtag'  => 'derde',
		   '4thtag'  => 'vierde'),

	          array('5thtag' => 'vijfde',
		   '6thtag' => 'sixth',
		   '7thtag' => 'zevende'));




foreach ($headtag as $subhead) {
	print "   <subhead>\n";
	foreach($subhead as $tag => $data) {
		print "       <$tag>" . htmlspecialchars($data) . "</$tag>\n";
		}
		print "   </subhead>\n";
}
print "</headtag>";
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Post by uberpolak »

What problem are you having?
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

re:

Post by ol4pr0 »

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

A name was started with an invalid character. Error processing resource 'http://localhost/'. Line 6, Position 9

<3thtag>derde</3thtag>
--------^
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

You can't start tag names with a number by the looks of it.

<3thtag> would be invalid... <thtag3> might work.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Yup, XML element names cannot start with a number.

Mac
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

thanks, but have a other error.

Post by ol4pr0 »

Thanks alot.

however i got a other error.. hoping you could help me on that one 2

$dom = domxml_new_doc('1.0'); <== something is wrong with this line.

compleet code

Code: Select all

// creating xml root node and subnode... for xml document
$dom = domxml_new_doc('1.0');
$root = $dom->append_child($dom->create_element('xml'));

$subnode1 = $root->append_child($dom->create_element('aduana-manifiesto'));
$subnode1->append_child($dom->create_text_node('$database_value+node1'));

$subnode2 = $root->append_child($dom->create_element('anio-manifiesto'));
$subnode2->append_child($dom->create_text_node('$database_value+node2'));

$subnode3 = $root->append_child($dom->create_element('tipo-manifiesto'));
$subnode3->append_child($dom->create_text_node('$database_value+node3'));

$subnode4 = $root->append_child($dom->create_element('subnode4'));
$subnode4->append_child($dom->create_text_node('$database_value+node4'));

$subnode5 = $root->append_child($dom->create_element('subnode5'));
$subnode5 ->append_child($dom->create_text_node('$database_value+node5'));

$subnode6 = $root->append_child($dom->create_element('subnode6'));
$subnode6->append_child($dom->create_text_node('$database_value+node6'));

$subnode7 = $root->append_child($dom->create_element('subnode7'));
$subnode7->append_child($dom->create_text_node('$database_value+node7'));

$subnode8 = $root->append_child($dom->create_element('subnode8'));
$subnode8->append_child($dom->create_text_node('$database_value+node8'));

$subnode9 = $root->append_child($dom->create_element('subnode9'));
$subnode9->append_child($dom->create_text_node('$database_value+node9'));

$subnode10 = $root->append_child($dom->create_element('subnode10'));
$subnode10 ->append_child($dom->create_text_node('$database_value+node10'));

$subnode11 = $root->append_child($dom->create_element('subnode11'));
$subnode11->append_child($dom->create_text_node('$database_value+node11'));

// putting the strings representing the xml document in $root
$root = $dom->dump_mem();
// writing the xml document to ( as shown in documents which are printed and discussed during meeting )
$dom->dump_file('document.xml', false, true);
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

When you use PHP's DOM functions you need to read the manual regularily as they are very much subject to change:
[php_man]dom_xml[/php_man]

Mac
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

read it.. mostly

Post by ol4pr0 »

i have read most of what relevant for me @ this moment..

however i still do not see why i get this error.

Fatal error: Call to undefined function: domxml_new_doc()
krash_control
Forum Newbie
Posts: 14
Joined: Mon Jan 12, 2004 10:02 am
Location: United Kingdom
Contact:

Post by krash_control »

Not too sure if this will make much of a difference but the example int the php doc uses double quotes instead of single quotes around the 1.0 (Sorry if it's irrelevant, I am trying to learn PHP bit by bit by looking how things are done in this forum and reading a book :D )
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

..

Post by ol4pr0 »

yea i know i have tried that one 2 hehe..

thanks tho..
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Are you using PHP 4.2.1 or above? Have you enabled the required module?

An undefined function is one that has not been enabled via a module or is not available on your version of PHP or is mispelled - basically it means PHP can't find the function you're trying to use.

Mac
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

version

Post by ol4pr0 »

i am using the php 4.3.3.

i didnt install a apache on my win2k.. instead i am using easyphp.

since the new apache giving me a very hard time ( 2.0.4.8 )
and also because this laptop is just to see if all works. :>
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have you enabled the module that you need to use the dom_xml_xxx() functions, as per the documentation that I linked to previously?

Mac
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

dll

Post by ol4pr0 »

yea i have the iconv.dll in my system32 if thats what youre asking me.
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

---

Post by ol4pr0 »

Well i got the apache installed finally with a php 4.3.4

However i still dont hve a clue on how to enable the dom-xml

or how to install the sql2xml..
trying to install the pear got me this
Loading zlib: ok Downloading package: PEAR.............ok Downloading package: Archive_Tar......ok Downloading package: Console_Getopt....ok Downloading package: XML_RPC..........ok Downloading package: Pager............ok Downloading package: HTML_Template_IT....ok Downloading package: Net_UserAgent_Detect....ok Downloading package: PEAR_Frontend_Web....ok Bootstrapping: PEAR...................
Not Found
The requested URL /co.php/php4/pear/PEAR.php was not found on this server.


--------------------------------------------------------------------------------

Apache/2.0.48 (Win32) PHP/4.3.3 Server at cvs.php.net Port 80
ok Bootstrapping: Archive_Tar............ok Bootstrapping: Console_Getopt.........ok Downloading package: DB...............ok Downloading package: Net_Socket.......ok Downloading package: Net_SMTP.........ok Downloading package: Mail.............ok Downloading package: XML_Parser.......ok
Fatal error: Undefined class name 'pear' in C:\Program Files\Apache Group\Apache2\htdocs\pear\pear.php on line 430

so if anybody knows how to do this..

Please let me know[/quote]
Post Reply