Page 1 of 1
Simple question
Posted: Wed Jan 14, 2004 2:11 pm
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>";
Posted: Wed Jan 14, 2004 5:37 pm
by uberpolak
What problem are you having?
re:
Posted: Wed Jan 14, 2004 5:51 pm
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>
--------^
Posted: Wed Jan 14, 2004 6:23 pm
by Gen-ik
You can't start tag names with a number by the looks of it.
<3thtag> would be invalid... <thtag3> might work.
Posted: Thu Jan 15, 2004 3:10 am
by twigletmac
Yup, XML element names cannot start with a number.
Mac
thanks, but have a other error.
Posted: Thu Jan 15, 2004 8:31 am
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);
Posted: Thu Jan 15, 2004 9:11 am
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
read it.. mostly
Posted: Thu Jan 15, 2004 9:30 am
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()
Posted: Thu Jan 15, 2004 9:41 am
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

)
..
Posted: Thu Jan 15, 2004 9:50 am
by ol4pr0
yea i know i have tried that one 2 hehe..
thanks tho..
Posted: Thu Jan 15, 2004 9:55 am
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
version
Posted: Thu Jan 15, 2004 10:00 am
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. :>
Posted: Thu Jan 15, 2004 10:11 am
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
dll
Posted: Thu Jan 15, 2004 10:17 am
by ol4pr0
yea i have the iconv.dll in my system32 if thats what youre asking me.
---
Posted: Thu Jan 15, 2004 2:46 pm
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]