Jump to content

Query on XML document

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
amberlong83

amberlong83

    Newbie

  • Members
  • Pip
  • 4 posts
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

<?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

<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.

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Moved to the PHP Forum.

You should use SimpleXML to read your XML document. It makes extracting values very easy.

#3
umapathyphp

umapathyphp

    Newbie

  • Members
  • Pip
  • 1 posts
Hi jordan,

Could u refer a sample code for this . I too in need of this

#4
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Sure, the best place to go is the manual: PHP: SimpleXML - Manual

#5
amberlong83

amberlong83

    Newbie

  • Members
  • Pip
  • 4 posts
thanks for reply