Jump to content

PHP to read XML


sridaran
 Share

Recommended Posts

Hi, I tried reading the following XML file using PHP. But it did not read. I deleted some contents and tried again. Now PHP reads and displays the XML file. I don't know the reason. Actually I need to create php forms like "image upload", "About-us page", "Register Page"...etc. While submitting the forms this xml file should be updated(on the related nodes) each time. Is all possible in PHP. Please help me.XML File<?xml version='1.0' encoding='UTF-8'?> <!-- This is the configuration xml, there are some short comments for each section, for more information refer to the help.txt file --> <content> <!-- General settings DO NOT REMOVE THIS TAGS!.. JUST SET THE CORRESPONDING SETTINGS! --> <text_links_normal_color>#FFFFFF</text_links_normal_color> <text_links_selected_color>#00CCFF</text_links_selected_color> <!-- Theme color for the menu buttons DO NOT REMOVE THIS TAGS!.. JUST SET THE CORRESPONDING SETTINGS!--> <menu_buttons_text_color_normal_state>#FFFFFF</menu_buttons_text_color_normal_state> <menu_buttons_text_color_selected_state>#000000</menu_buttons_text_color_selected_state> <!-- Background settings DO NOT REMOVE THIS TAGS!.. JUST SET THE CORRESPONDING SETTINGS! --> <show_background_mesh>yes</show_background_mesh> <background_image_path>content/background_image/image.jpg</background_image_path> <!-- Main menu gallery settings DO NOT REMOVE THIS TAGS!.. JUST SET THE CORRESPONDING SETTINGS! --> <thumb_height>160</thumb_height> <preloader_color>#FFFFFF</preloader_color> <thumb_outline_normal_color>#595959</thumb_outline_normal_color> <thumb_outline_selected_color>#FFFFFF</thumb_outline_selected_color> <scrollbar_handler_icon_normal_color>#FFFFFF</scrollbar_handler_icon_normal_color> <scrollbar_handler_icon_selected_color>#000000</scrollbar_handler_icon_selected_color> <!-- Copyright text settings DO NOT REMOVE THIS TAGS!.. JUST SET THE CORRESPONDING SETTINGS! --> <show_copyright_text>yes</show_copyright_text> <copyright_text><![CDATA[<font color="#FFFFFF">© 2010 - Photographer name | Email: <a href="mailto:your_email@your_domain.com">your_email@your_domain.com</a> | Tel: +40070788557</font>]]></copyright_text> <background_color>#000000</background_color> <!-- Logo settings DO NOT REMOVE THIS TAGS!.. JUST SET THE CORRESPONDING SETTINGS! --> <show_logo>yes</show_logo> <allow_mouse_click>yes</allow_mouse_click> <logo_path>content/logo/logo.png</logo_path> <!-- Sound and full screen button settings DO NOT REMOVE THIS TAGS!.. JUST SET THE CORRESPONDING SETTINGS! --> <show_sound_button>yes</show_sound_button> <show_fullscreen_button>yes</show_fullscreen_button> <sound_path>content/sound/my.mp3</sound_path> <loop_sound>yes</loop_sound> <!-- Video player settings DO NOT REMOVE THIS TAGS!.. JUST SET THE CORRESPONDING SETTINGS! --> <show_video>yes</show_video> <video_button_label>VIDEO COLLECTION</video_button_label> <vido_xml_path>content/video/config.xml</vido_xml_path> <!-- Contect form text DO NOT REMOVE THIS TAGS!.. JUST SET THE CORRESPONDING SETTINGS! --> <show_contact>yes</show_contact> <contact_button_label>CONTACT US</contact_button_label> <contact_text><![CDATA[You can add here custom text, the contact form will resize based on the text length! <br><br>Email: <a href="mailto:your_email@your_domain.com">your_email@your_domain.com</a><br><br>Tel: <font color="#9E9E9E">+40070788557</font>]]></contact_text> <contact_labels_color>#FFFFFF</contact_labels_color> <contact_inputs_color>#9E9E9E</contact_inputs_color> <!-- Custom windows settings YOU CAN ADD OR REMOVE CUSTOM WINDOWS HERE... IF YOU DON'T WANT ANY CUSTOM WINDOW REMOVE THE ALL custom_window TAGS BELOW --> <scroll_bar_handler_icon_normal_clolor>#9E9E9E</scroll_bar_handler_icon_normal_clolor> <scroll_bar_handler_icon_selected_clolor>#FFFFFF</scroll_bar_handler_icon_selected_clolor> <custom_window> <width>500</width> <button_label>ABOUT US</button_label> <text><![CDATA[YOU CAN ADD AS MANY TEXT AS YOU NEED.<br><font color="#9E9E9E">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed iaculis felis nec enim lobortis laoreet. Curabitur tempus eros et lacus ullamcorper sagittis. Mauris ut metus felis, at pulvinar magna. Ut ullamcorper molestie nulla, id euismod leo tempus at. Praesent adipiscing est tincidunt neque pretium fermentum. Fusce nec tellus at nibh commodo vulputate.</font><br><br>A SCROLLBAR WILL APPEAR IF THE TEXT IS TO LARGE.<br>YOU CAN ADD AS MANY WINDOW LIKE THIS ONE AS YOU NEED, CHANGE THE LABEL AND THE CONTENT FOR THEM... ALL THIS AND THE SETUP OF THE ENTIRE TEMPLATE IS MADE FROM AN EXTERNAL XML FILE... THIS MEANS THAT YOU DON'T NEED TO KNOW FLASH AT ALL!]]></text> </custom_window> <custom_window> <width>500</width> <button_label>LATEST NEWS</button_label> <text><![CDATA[YOU CAN ADD AS MANY TEXT AS YOU NEED.<br><font color="#9E9E9E">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed iaculis felis nec enim lobortis laoreet. Curabitur tempus eros et lacus ullamcorper sagittis. Mauris ut metus felis, at pulvinar magna. Ut ullamcorper molestie nulla, id euismod leo tempus at. Praesent adipiscing est tincidunt neque pretium fermentum. Fusce nec tellus at nibh commodo vulputate.</font><br></text> </custom_window> <!-- External links YOU CAN ADD OR REMOVE EXTERNAL LINKS BUTTON HERE...IF YOU DON'T WANT ANY EXTERNAL LINK BUTTON REMOVE THE ALL link TAGS BELOW --> <external_link> <button_label>EXTERNAL LINK1</button_label> <url_to_open>http://www.flashcomponents.net/author/FWDesign.html</url_to_open> <target>_blank</target> </external_link> <!-- Galleries setup HERE YOU CAN ADD OR REMOVE GALLERIES... YOU NEED TO HAVE AT LEAST ONE GALLERY IN ORDER FOR THIS TEMPLATE TO WORK --> <gallery_menu_button_label>IMAGE COLLECTION</gallery_menu_button_label> <gallery> <gallery_label>BEAUTY COLLECTION</gallery_label> <thumb_path>content/main_menu_thumbs/1.jpg</thumb_path> <xml_gallery_path>content/gallery1/config.xml</xml_gallery_path> </gallery> <gallery> <gallery_label>FASHION & STYLE</gallery_label> <thumb_path>content/main_menu_thumbs/2.jpg</thumb_path> <xml_gallery_path>content/gallery2/config.xml</xml_gallery_path> </gallery> <gallery> <gallery_label>COLLECTION 2010</gallery_label> <thumb_path>content/main_menu_thumbs/3.jpg</thumb_path> <xml_gallery_path>content/gallery2/config.xml</xml_gallery_path> </gallery> </content>R.Sridaran

Link to comment
Share on other sites

Thanks for quick response. I tried simple xml. But I was not able to read the complete file. If I delete some contents then I can able to read the file. My file size is 18.5 KB. Is it necessary to make any changes on the PHP configuration file (or) Shall I try PHP XML DOM or PHP XML SAX Parser. Which would be the best solution?R.Sridaran

Link to comment
Share on other sites

Is this the complete XML you're trying to read? What exactly is the code you're using (copy&paste the PHP code itself)? What exactly do you expect to get, and what do you get instead?

Link to comment
Share on other sites

I am getting blank page if I read this xml file. If I delete some contents then the script is reading the total file. Actually my task is to make updations on the xml file through PHP Form. As a first step I want to read this XML file.Here are my PHP code and XML Codes:PHP Code : 1<?php$xml = simplexml_load_file("config.xml");echo $xml->getName() . "<br />";foreach($xml->children() as $child) { if($child->getName()=="custom_window") echo $child->getName() . ": " . $child . "<br />"; foreach($child->children() as $c){ if($c->getName()=="text") echo $c->getName() . ": " . $c . "<br />"; } }?>PHP Code : 2<?php$xmlDoc = new DOMDocument();$xmlDoc->load("config.xml");$x = $xmlDoc->documentElement;foreach ($x->childNodes AS $item) { print $item->nodeName . " = " . $item->nodeValue . "<br />"; }?>XML Code(config.xml)<?xml version='1.0' encoding='UTF-8'?> <!-- This is the configuration xml, there are some short comments for each section, for more information refer to the help.txt file --> <content> <!-- General settings DO NOT REMOVE THIS TAGS!.. JUST SET THE CORRESPONDING SETTINGS! --> <text_links_normal_color>#FFFFFF</text_links_normal_color> <text_links_selected_color>#00CCFF</text_links_selected_color> <!-- Theme color for the menu buttons DO NOT REMOVE THIS TAGS!.. JUST SET THE CORRESPONDING SETTINGS!--> <menu_buttons_text_color_normal_state>#FFFFFF</menu_buttons_text_color_normal_state> <menu_buttons_text_color_selected_state>#000000</menu_buttons_text_color_selected_state> <menu_buttons_background_color_normal_state>#000000</menu_buttons_background_color_normal_state> <menu_buttons_background_color_selected_state>#FFFFFF</menu_buttons_background_color_selected_state> <!-- Background settings DO NOT REMOVE THIS TAGS!.. JUST SET THE CORRESPONDING SETTINGS! --> <show_background_mesh>yes</show_background_mesh> <background_image_path>content/background_image/image.jpg</background_image_path> <!-- Main menu gallery settings DO NOT REMOVE THIS TAGS!.. JUST SET THE CORRESPONDING SETTINGS! --> <thumb_height>160</thumb_height> <preloader_color>#FFFFFF</preloader_color> <thumb_label_up_color>#FFFFFF</thumb_label_up_color> <thumb_label_down_color>#595959</thumb_label_down_color> <thumb_outline_normal_color>#595959</thumb_outline_normal_color> <thumb_outline_selected_color>#FFFFFF</thumb_outline_selected_color> <scrollbar_handler_icon_normal_color>#FFFFFF</scrollbar_handler_icon_normal_color> <scrollbar_handler_icon_selected_color>#000000</scrollbar_handler_icon_selected_color> <scrollbar_handler_background_normal_color>#000000</scrollbar_handler_background_normal_color> <scrollbar_handler_background_selected_color>#FFFFFF</scrollbar_handler_background_selected_color> <!-- Copyright text settings DO NOT REMOVE THIS TAGS!.. JUST SET THE CORRESPONDING SETTINGS! --> <show_copyright_text>yes</show_copyright_text> <copyright_text><![CDATA[<font color="#FFFFFF">© 2010 - Photographer name | Email: <a href="mailto:your_email@your_domain.com">your_email@your_domain.com</a> | Tel: +40070788557</font>]]></copyright_text> <background_color>#000000</background_color> <!-- Logo settings DO NOT REMOVE THIS TAGS!.. JUST SET THE CORRESPONDING SETTINGS! --> <show_logo>yes</show_logo> <allow_mouse_click>yes</allow_mouse_click> <logo_path>content/logo/logo.png</logo_path> <!-- Sound and full screen button settings DO NOT REMOVE THIS TAGS!.. JUST SET THE CORRESPONDING SETTINGS! --> <show_sound_button>yes</show_sound_button> <show_fullscreen_button>yes</show_fullscreen_button> <sound_path>content/sound/my.mp3</sound_path> <loop_sound>yes</loop_sound> <!-- Video player settings DO NOT REMOVE THIS TAGS!.. JUST SET THE CORRESPONDING SETTINGS! --> <show_video>yes</show_video> <video_button_label>VIDEO COLLECTION</video_button_label> <vido_xml_path>content/video/config.xml</vido_xml_path> <!-- Contect form text DO NOT REMOVE THIS TAGS!.. JUST SET THE CORRESPONDING SETTINGS! --> <show_contact>yes</show_contact> <contact_button_label>CONTACT US</contact_button_label> <contact_text><![CDATA[You can add here custom text, the contact form will resize based on the text length! <br><br>Email: <a href="mailto:your_email@your_domain.com">your_email@your_domain.com</a><br><br>Tel: <font color="#9E9E9E">+40070788557</font>]]></contact_text> <contact_labels_color>#FFFFFF</contact_labels_color> <contact_inputs_color>#9E9E9E</contact_inputs_color> <!-- Custom windows settings YOU CAN ADD OR REMOVE CUSTOM WINDOWS HERE... IF YOU DON'T WANT ANY CUSTOM WINDOW REMOVE THE ALL custom_window TAGS BELOW --> <scroll_bar_handler_icon_normal_clolor>#9E9E9E</scroll_bar_handler_icon_normal_clolor> <scroll_bar_handler_icon_selected_clolor>#FFFFFF</scroll_bar_handler_icon_selected_clolor> <custom_window> <width>500</width> <button_label>ABOUT US</button_label> <text><![CDATA[YOU CAN ADD AS MANY TEXT AS YOU NEED.<br><font color="#9E9E9E">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed iaculis felis nec enim lobortis laoreet. Curabitur tempus eros et lacus ullamcorper sagittis. Mauris ut metus felis, at pulvinar magna. Ut ullamcorper molestie nulla, id euismod leo tempus at. Praesent adipiscing est tincidunt neque pretium fermentum. Fusce nec tellus at nibh commodo vulputate.</font><br><br>A SCROLLBAR WILL APPEAR IF THE TEXT IS TO LARGE.<br><font color="#9E9E9E">Maecenas dolor ante, semper in imperdiet vel, laoreet nec urna. Morbi sit amet lorem nibh, eu aliquet neque. Etiam quis diam purus. Ut urna quam, vehicula vitae placerat vel, tristique sit amet arcu. Nunc et orci turpis. Duis tellus dolor, egestas nec porttitor vitae, blandit ut mauris.Vivamus dapibus mauris vel quam ullamcorper fringilla scelerisque risus dapibus. Donec non libero quis est elementum dignissim. Suspendisse at dui faucibus magna venenatis adipiscing non non mauris.</font><br><br>THIS IS HTML FORMATTED TEXT.<br><font color="#9E9E9E">Fusce eu enim vel nunc condimentum tincidunt a ac nulla. Praesent molestie nunc <font color="#CCCCCC">You can change the color.</font> nec laoreet orci tincidunt. Pellentesque urna turpis, lacinia quis egestas vitae, tincidunt eget nibh. Sed magna orci, vestibulum at faucibus sit amet, dignissim nec lorem. Nullam hendrerit imperdiet odio. In luctus ornare magna, vitae dapibus lorem adipiscing at. Quisque fermentum adipiscing nibh sed pellentesque. <a href="http://www.flashcomponents.net/author/FWDesign.html" target="_blank">You can add external links.</a>Vivamus enim turpis, faucibus id scelerisque eleifend, elementum eu enim. Vestibulum vel erat sed elit interdum luctus a id mi. Fusce posuere consequat ligula ac tempor. Sed lobortis adipiscing augue, eget molestie purus dictum quis. In nunc nulla, consectetur eget lacinia et, varius et tellus. Nunc at erat nisi, sit amet vehicula lorem. Etiam eu mauris tortor, et ornare lacus. Fusce ante turpis, convallis id porta ut, lacinia nec sapien.</font><br><br>YOU CAN ADD IMAGES OR SWF FILES!<br><br><img src="content/custom_window_images/image1.png" hspace="0" vspace="5" width="156" height="98"/><font color="#9E9E9E">Nullam nisi ante, pretium ac ultrices nec, tristique euismod libero. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet diam et mi accumsan non lobortis enim dapibus. Cras venenatis vulputate magna ac porta. Fusce sed enim enim. Nunc laoreet nulla vel sem varius a porttitor magna blandit. Vestibulum egestas lectus eget sem mollis at tempus sem malesuada. Aenean accumsan dolor quis dolor laoreet vel feugiat justo suscipit.</font><br><br><img src="content/custom_window_images/image2.png" width="156" height="98" hspace="0" vspace="6"/><font color="#9E9E9E">Nullam nisi ante, pretium ac ultrices nec, tristique euismod libero. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet diam et mi accumsan non lobortis enim dapibus. Cras venenatis vulputate magna ac porta. Fusce sed enim enim. Nunc laoreet nulla vel sem varius a porttitor magna blandit. Vestibulum egestas lectus eget sem mollis at tempus sem malesuada. Aenean accumsan dolor quis dolor laoreet vel feugiat justo suscipit.</font><br><br>YOU CAN ADD AS MANY WINDOW LIKE THIS ONE AS YOU NEED, CHANGE THE LABEL AND THE CONTENT FOR THEM... ALL THIS AND THE SETUP OF THE ENTIRE TEMPLATE IS MADE FROM AN EXTERNAL XML FILE... THIS MEANS THAT YOU DON'T NEED TO KNOW FLASH AT ALL!]]></text> </custom_window> <custom_window> <width>500</width> <button_label>LATEST NEWS</button_label> <text><![CDATA[YOU CAN ADD AS MANY TEXT AS YOU NEED.<br><font color="#9E9E9E">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed iaculis felis nec enim lobortis laoreet. Curabitur tempus eros et lacus ullamcorper sagittis. Mauris ut metus felis, at pulvinar magna. Ut ullamcorper molestie nulla, id euismod leo tempus at. Praesent adipiscing est tincidunt neque pretium fermentum. Fusce nec tellus at nibh commodo vulputate.</font><br><br>A SCROLLBAR WILL APPEAR IF THE TEXT IS TO LARGE.<br><font color="#9E9E9E">Maecenas dolor ante, semper in imperdiet vel, laoreet nec urna. Morbi sit amet lorem nibh, eu aliquet neque. Etiam quis diam purus. Ut urna quam, vehicula vitae placerat vel, tristique sit amet arcu. Nunc et orci turpis. Duis tellus dolor, egestas nec porttitor vitae, blandit ut mauris.Vivamus dapibus mauris vel quam ullamcorper fringilla scelerisque risus dapibus. Donec non libero quis est elementum dignissim. Suspendisse at dui faucibus magna venenatis adipiscing non non mauris.</font><br><br>THIS IS HTML FORMATTED TEXT.<br><font color="#9E9E9E">Fusce eu enim vel nunc condimentum tincidunt a ac nulla. Praesent molestie nunc <font color="#CCCCCC">You can change the color.</font> nec laoreet orci tincidunt. Pellentesque urna turpis, lacinia quis egestas vitae, tincidunt eget nibh. Sed magna orci, vestibulum at faucibus sit amet, dignissim nec lorem. Nullam hendrerit imperdiet odio. In luctus ornare magna, vitae dapibus lorem adipiscing at. Quisque fermentum adipiscing nibh sed pellentesque. <a href="http://www.flashcomponents.net/author/FWDesign.html" target="_blank">You can add external links.</a>Vivamus enim turpis, faucibus id scelerisque eleifend, elementum eu enim. Vestibulum vel erat sed elit interdum luctus a id mi. Fusce posuere consequat ligula ac tempor. Sed lobortis adipiscing augue, eget molestie purus dictum quis. In nunc nulla, consectetur eget lacinia et, varius et tellus. Nunc at erat nisi, sit amet vehicula lorem. Etiam eu mauris tortor, et ornare lacus. Fusce ante turpis, convallis id porta ut, lacinia nec sapien.</font><br><br>YOU CAN ADD IMAGES OR SWF FILES!<br><br><img src="content/custom_window_images/image1.png" hspace="0" vspace="5" width="156" height="98"/><font color="#9E9E9E">Nullam nisi ante, pretium ac ultrices nec, tristique euismod libero. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet diam et mi accumsan non lobortis enim dapibus. Cras venenatis vulputate magna ac porta. Fusce sed enim enim. Nunc laoreet nulla vel sem varius a porttitor magna blandit. Vestibulum egestas lectus eget sem mollis at tempus sem malesuada. Aenean accumsan dolor quis dolor laoreet vel feugiat justo suscipit.</font><br><br><img src="content/custom_window_images/image2.png" width="156" height="98" hspace="0" vspace="6"/><font color="#9E9E9E">Nullam nisi ante, pretium ac ultrices nec, tristique euismod libero. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet diam et mi accumsan non lobortis enim dapibus. Cras venenatis vulputate magna ac porta. Fusce sed enim enim. Nunc laoreet nulla vel sem varius a porttitor magna blandit. Vestibulum egestas lectus eget sem mollis at tempus sem malesuada. Aenean accumsan dolor quis dolor laoreet vel feugiat justo suscipit.</font><br><br><img src="content/custom_window_images/image1.png" hspace="0" vspace="5" width="156" height="98"/><font color="#9E9E9E">Nullam nisi ante, pretium ac ultrices nec, tristique euismod libero. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet diam et mi accumsan non lobortis enim dapibus. Cras venenatis vulputate magna ac porta. Fusce sed enim enim. Nunc laoreet nulla vel sem varius a porttitor magna blandit. Vestibulum egestas lectus eget sem mollis at tempus sem malesuada. Aenean accumsan dolor quis dolor laoreet vel feugiat justo suscipit.</font><br><br><img src="content/custom_window_images/image2.png" width="156" height="98" hspace="0" vspace="6"/><font color="#9E9E9E">Nullam nisi ante, pretium ac ultrices nec, tristique euismod libero. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet diam et mi accumsan non lobortis enim dapibus. Cras venenatis vulputate magna ac porta. Fusce sed enim enim. Nunc laoreet nulla vel sem varius a porttitor magna blandit. Vestibulum egestas lectus eget sem mollis at tempus sem malesuada. Aenean accumsan dolor quis dolor laoreet vel feugiat justo suscipit.</font><br><br><img src="content/custom_window_images/image1.png" hspace="0" vspace="5" width="156" height="98"/><font color="#9E9E9E">Nullam nisi ante, pretium ac ultrices nec, tristique euismod libero. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet diam et mi accumsan non lobortis enim dapibus. Cras venenatis vulputate magna ac porta. Fusce sed enim enim. Nunc laoreet nulla vel sem varius a porttitor magna blandit. Vestibulum egestas lectus eget sem mollis at tempus sem malesuada. Aenean accumsan dolor quis dolor laoreet vel feugiat justo suscipit.</font><br><br><img src="content/custom_window_images/image2.png" width="156" height="98" hspace="0" vspace="6"/><font color="#9E9E9E">Nullam nisi ante, pretium ac ultrices nec, tristique euismod libero. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet diam et mi accumsan non lobortis enim dapibus. Cras venenatis vulputate magna ac porta. Fusce sed enim enim. Nunc laoreet nulla vel sem varius a porttitor magna blandit. Vestibulum egestas lectus eget sem mollis at tempus sem malesuada. Aenean accumsan dolor quis dolor laoreet vel feugiat justo suscipit.</font><br><br><img src="content/custom_window_images/image1.png" hspace="0" vspace="5" width="156" height="98"/><font color="#9E9E9E">Nullam nisi ante, pretium ac ultrices nec, tristique euismod libero. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet diam et mi accumsan non lobortis enim dapibus. Cras venenatis vulputate magna ac porta. Fusce sed enim enim. Nunc laoreet nulla vel sem varius a porttitor magna blandit. Vestibulum egestas lectus eget sem mollis at tempus sem malesuada. Aenean accumsan dolor quis dolor laoreet vel feugiat justo suscipit.</font><br><br><img src="content/custom_window_images/image2.png" width="156" height="98" hspace="0" vspace="6"/><font color="#9E9E9E">Nullam nisi ante, pretium ac ultrices nec, tristique euismod libero. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet diam et mi accumsan non lobortis enim dapibus. Cras venenatis vulputate magna ac porta. Fusce sed enim enim. Nunc laoreet nulla vel sem varius a porttitor magna blandit. Vestibulum egestas lectus eget sem mollis at tempus sem malesuada. Aenean accumsan dolor quis dolor laoreet vel feugiat justo suscipit.</font><br><br>YOU CAN ADD AS MANY WINDOW LIKE THIS ONE AS YOU NEED, CHANGE THE LABEL AND THE CONTENT FOR THEM... ALL THIS AND THE SETUP OF THE ENTIRE TEMPLATE IS MADE FROM AN EXTERNAL XML FILE... THIS MEANS THAT YOU DON'T NEED TO KNOW FLASH AT ALL!]]></text> </custom_window> <!-- External links YOU CAN ADD OR REMOVE EXTERNAL LINKS BUTTON HERE...IF YOU DON'T WANT ANY EXTERNAL LINK BUTTON REMOVE THE ALL link TAGS BELOW --> <external_link> <button_label>EXTERNAL LINK1</button_label> <url_to_open>http://www.flashcomponents.net/author/FWDesign.html</url_to_open> <target>_blank</target> </external_link> <external_link> <button_label>EXTERNAL LINK2</button_label> <url_to_open>http://www.flashcomponents.net/author/FWDesign.html</url_to_open> <target>_blank</target> </external_link> <!-- Galleries setup HERE YOU CAN ADD OR REMOVE GALLERIES... YOU NEED TO HAVE AT LEAST ONE GALLERY IN ORDER FOR THIS TEMPLATE TO WORK --> <gallery_menu_button_label>IMAGE COLLECTION</gallery_menu_button_label> <gallery> <gallery_label>BEAUTY COLLECTION</gallery_label> <thumb_path>content/main_menu_thumbs/1.jpg</thumb_path> <xml_gallery_path>content/gallery1/config.xml</xml_gallery_path> </gallery> <gallery> <gallery_label>FASHION & STYLE</gallery_label> <thumb_path>content/main_menu_thumbs/2.jpg</thumb_path> <xml_gallery_path>content/gallery2/config.xml</xml_gallery_path> </gallery> <gallery> <gallery_label>COLLECTION 2010</gallery_label> <thumb_path>content/main_menu_thumbs/3.jpg</thumb_path> <xml_gallery_path>content/gallery2/config.xml</xml_gallery_path> </gallery> <gallery> <gallery_label>YOU CAN SET YOUR ONE LABEL</gallery_label> <thumb_path>content/main_menu_thumbs/4.jpg</thumb_path> <xml_gallery_path>content/gallery1/config.xml</xml_gallery_path> </gallery> <gallery> <gallery_label>UNDERWATER</gallery_label> <thumb_path>content/main_menu_thumbs/5.jpg</thumb_path> <xml_gallery_path>content/gallery2/config.xml</xml_gallery_path> </gallery> <gallery> <gallery_label>FINEART / PORTRAITS</gallery_label> <thumb_path>content/main_menu_thumbs/6.jpg</thumb_path> <xml_gallery_path>content/gallery2/config.xml</xml_gallery_path> </gallery> <gallery> <gallery_label>RECENT PHOTOS</gallery_label> <thumb_path>content/main_menu_thumbs/7.jpg</thumb_path> <xml_gallery_path>content/gallery2/config.xml</xml_gallery_path> </gallery> <gallery> <gallery_label>CUSTOM LABEL FOR YOUR GALLERY</gallery_label> <thumb_path>content/main_menu_thumbs/8.jpg</thumb_path> <xml_gallery_path>content/gallery2/config.xml</xml_gallery_path> </gallery> <gallery> <gallery_label>BEAUTY COLLECTION</gallery_label> <thumb_path>content/main_menu_thumbs/1.jpg</thumb_path> <xml_gallery_path>content/gallery1/config.xml</xml_gallery_path> </gallery> <gallery> <gallery_label>FASHION & STYLE</gallery_label> <thumb_path>content/main_menu_thumbs/2.jpg</thumb_path> <xml_gallery_path>content/gallery2/config.xml</xml_gallery_path> </gallery> <gallery> <gallery_label>COLLECTION 2010</gallery_label> <thumb_path>content/main_menu_thumbs/3.jpg</thumb_path> <xml_gallery_path>content/gallery2/config.xml</xml_gallery_path> </gallery> <gallery> <gallery_label>YOU CAN SET YOUR ONE LABEL</gallery_label> <thumb_path>content/main_menu_thumbs/4.jpg</thumb_path> <xml_gallery_path>content/gallery1/config.xml</xml_gallery_path> </gallery> <gallery> <gallery_label>UNDERWATER</gallery_label> <thumb_path>content/main_menu_thumbs/5.jpg</thumb_path> <xml_gallery_path>content/gallery2/config.xml</xml_gallery_path> </gallery> <gallery> <gallery_label>FINEART / PORTRAITS</gallery_label> <thumb_path>content/main_menu_thumbs/6.jpg</thumb_path> <xml_gallery_path>content/gallery2/config.xml</xml_gallery_path> </gallery> <gallery> <gallery_label>RECENT PHOTOS</gallery_label> <thumb_path>content/main_menu_thumbs/7.jpg</thumb_path> <xml_gallery_path>content/gallery2/config.xml</xml_gallery_path> </gallery> <gallery> <gallery_label>CUSTOM LABEL FOR YOUR GALLERY</gallery_label> <thumb_path>content/main_menu_thumbs/8.jpg</thumb_path> <xml_gallery_path>content/gallery2/config.xml</xml_gallery_path> </gallery> </content>

Link to comment
Share on other sites

Just what I thought... Your XML is not well-formed. Sorry for not seeing the exact error location earlier, but if you had error messages in PHP on, you'd have seen it before us all. Line 98 and 146 of your XML:

<gallery_label>FASHION & STYLE</gallery_label>

"&" is a special character, so you need to explicitly escape it, like:

<gallery_label>FASHION & STYLE</gallery_label>

Escaping those two amps is going to make both of your test files work. BTW, I'd reccomend using DOM. If you already know it from JavaScript, you can carry most of your knowledge here, and if you don't know it from JavaScript yet, learning it from PHP will help you learn it more easily in JavaScript.And in case you don't know how to enable error messages in PHP - from your php.ini, search for

error_reporting =

and make the whole line read

error_reporting = E_ALL | E_STRICT

(this is to ensure you see all errors, including good code practices)Also, search for

display_errors =

and make the whole line read

display_errors = On

(this is to make sure you see errors on screen... you can alternatively make them be written to a file, but that's probably not a good idea during development)And finally save the file of course. You may have to restart your web server for the changes to take effect.

Link to comment
Share on other sites

Thank you for letting me know the XML Error. I corrected it and now my php is reading the xml file. Also I set the php configuration file to enable error display. Now my work starts. I need to modify the xml file by submitting the php form. Is it possible to identify and replace any particular node from the above xml. This is new to me. Can you help me? I am trying the following code and getting parse error:xmlDoc=loadXMLDoc("config.xml");x=xmlDoc.getElementsByTagName("external_link")[0].childNodes[0];x.nodeValue="www.google.co.in";R.Sridaran

Link to comment
Share on other sites

The DOM codes from W3Schools are for JavaScript. You need to use the PHP equivalents.You had the right idea with your second PHP sample... here's the JavaScript translated to its PHP equivalent:

<?php$xmlDoc = new DOMDocument();$xmlDoc->load("config.xml");$x = $xmlDoc->getElementsByTagName("external_link")->item(0)->childNodes->item(0);$x->nodeValue = "www.google.co.in";/* Only if you want to save the changes, as opposed to just using altering the XML "one time" and keep using the old file in subsequent executions...JavaScript can't do that. */$xmlDoc->save("config.xml");?>

If in doubt about a function name or arguments, it's best to look in the PHP DOM reference.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...