tags:

views:

42

answers:

2

Dear all,

Using my below code i can read < abcxyz > xml tag easily. but how can i read the data between < abc : xyz > < / abc: xml > xml tag.. xml tag using php.pls help....

my php sample code...

 $objDOM->load("abc.xml"); 
  $note = $objDOM->getElementsByTagName("note");  
   foreach( $note as $value )
   {
    $tasks = $value->getElementsByTagName("tasks");
    $task  = $tasks->item(0)->nodeValue;
    $details = $value->getElementsByTagName("details");
    $detail  = $details->item(0)->nodeValue;    
    echo "$task :: $detail<br>";
   }

My XML sample code:

<mynotes>
     <note>
        <tasks>Task 1</tasks>
        <details>Detail 1</details>
     </note>
     <abc:xyz> Cannot Read the XML data between this tag</abc:xyz>
 </mynotes>

Pls guide me...

Thanks
Riad

+2  A: 

you need DOMDocument::getElementsByTagNameNS

kgb
could you pls give me an example..because on that link i don't get any proper example..
riad
using this example i get the abc and xyz into a seperated variable like $v1 and $v2.But i cannot put $value->getElementsByTagName($v1,$v2); on this function to get value between this..I need the value between this tag
riad
+2  A: 

abc:xyz means that the element is named xyz, and the namespace is indicated by abc. The namespace part is actually shorthand for an URI, which is usually also given in the XML file. For example, you may see this:

xmlns:abc="http://www.abc.com/xml"

In this case, elements which have abc before the colon are in the namespace http://www.abc.com/xml.

To retrieve this element, you need to use getElementsByTagNameNS and pass http://www.abc.com/xml as the namespace.

Sjoerd