Jump to content

Trying to get multiple xml tags to display


Z33M@N

Recommended Posts

 

The XML :

 

<LEVEL style-name="Normal Level" style-name-escaped="Normal-Level" style-id="0-0-0-0" level-depth="0" toc-section="false">
			<RECORD id="0-0-0-11" number="11" version="94">
				<PARA style-name="pCenter-8" style-name-escaped="pCenter-8" style-id="0-0-0-53">
					<PICTURE id="0-0-0-25173-img" object-class="folio objects" name="SAE_Forward_09.jpg" href="#!-- #EXECUTIVE:HOME_PATH --#/img/SAE_Forward_09.jpg" width="6870" height="810" left-border-line-color="0" left-border-line-width="0" left-border-space="0" right-border-line-color="0" right-border-line-width="0" right-border-space="0" top-border-line-color="0" top-border-line-width="0" top-border-space="0" bottom-border-line-color="0" bottom-border-line-width="0" bottom-border-space="0"/>
				</PARA>
			</RECORD>
			<RECORD id="0-0-0-12" number="12" version="3">
				<PARA>
				</PARA>
			</RECORD>
			<RECORD id="0-0-0-16" number="13" version="84">
				<PARA>Test data.</PARA>
			</RECORD>
			<RECORD id="0-0-0-250329" number="14" version="84">
				<PARA>Test Data</PARA>
			</RECORD>
			<RECORD id="0-0-0-250330" number="15" version="84">
				<PARA>Test Data</PARA>
			</RECORD>
			<RECORD id="0-0-0-250331" number="16" version="84">
				<PARA>test.</PARA>
			</RECORD>
			<RECORD id="0-0-0-250332" number="17" version="84">
				<PARA>test</PARA>
			</RECORD>
		</LEVEL>

 

What I want to do is get the the RECORD TAGS and the PICTURE TAGS attribute "href", my code :

 

$doc = new DOMDocument();

  $doc->load( 'xml/english/0-0-0-10.xml' );
  
  //get xml data and display it, then store in to mysql table.
  //$rows = $doc->getElementsByTagName( "ROW" );
  $rows = $doc->getElementsByTagName( "RECORD" );
  foreach( $rows as $row )
  {
  $links = $row->getElementsByTagName( "PARA" );
  $link = $links->item(0)->nodeValue;
  
  $picture = $row->getElementsByTagName( "PICTURE" );
  $pict = $picture->get_attribute('href');

  echo "<p>$link</p><p>$pict</p>";
  
  }

 

I'm getting the following error Call to undefined method DOMNodeList::get_attribute() .

 

What am I doing wrong? :confused:

Link to comment
Share on other sites

$picture->item(0)->getAttribute(..)

 

This is my code:

 

$picture = $row->getElementsByTagName( "PICTURE" );

  $picture->item(0)->getAttribute('href');

 

I'm still getting that error -> Fatal error: Call to a member function getAttribute() on a non-object in....

 

Could it be because I'm using a local server for testing?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.