NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Query on XML document

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Reply
 
LinkBack Thread Tools
Old 06-23-2009, 04:55 AM THREAD STARTER               #1 (permalink)
First Time Poster!
Join Date: Jun 2009
Posts: 1
amber.long83 is an unknown quantity at this point
 



Query on XML document


Hi friends

I am working with PHP5 and have a requirement to select xml node on the base of parameter. My xml contains the list of country and it has child node of state list. Like this

HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<country_list>
	<country id="US">
		<state>NY</state>
		<state>CA</state>
		<state>NJ</state>		
	</country>
	<country id="AU">
		<state>New South Wales</state>		
		<state>Victoria</state>				
		<state>Queensland</state>						
	</country>	
</country_list>
I want to get the xml like
????: NamePros.com http://www.namepros.com/programming/591829-query-on-xml-document.html

HTML Code:
<country id="AU">
		<state>New South Wales</state>		
		<state>Victoria</state>				
		<state>Queensland</state>						
	</country>
Can anyone help me how can I achieve this?

thanks in advance.
__________________
Magento Developer
amber.long83 is offline   Reply With Quote
Old 06-23-2009, 08:13 AM   #2 (permalink)
NamePros Member
Join Date: Sep 2006
Posts: 99
Bruce_KD will become famous soon enoughBruce_KD will become famous soon enough
 



PHP Code:
<?php

header
('Content-type: text/xml');

$xml = new SimpleXMLElement('<?xml version="1.0"?><country_list> </country_list>');
$country $xml->addChild('country');
$country->addAttribute('id''US');
????: NamePros.com http://www.namepros.com/showthread.php?t=591829

$country->addChild('state''NY');
$country->addChild('state''CA');
$country->addChild('state''NJ');

echo 
$xml->asXML();

?>
Untested but modified from previous code.


Bruce
Bruce_KD is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Complete XML parser Barrucadu CODE 0 01-04-2009 07:35 AM
Help setting up HTTP XML Feed James B Programming 4 02-18-2008 01:53 AM
encrypt and decrypt query string sales@vannova.com Programming 5 06-07-2007 12:45 AM
XML API SOAP Installation Billy! Web Development Wanted 0 05-08-2007 07:56 AM
Site conversion from mysql to XML Chuppa Programming 5 10-14-2006 05:50 AM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 02:44 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger