0

I have a php script that retrieves an XML file from a database and displays it in html.

I only want to display some parameters from the XML in my html, I was wondering what was the best way to do it.

Suppose that bellow I would only like to display the Format and TIM attributes of the XML. What would I need to modify on the html? I've read that I can delete elements using XSLT but then I would need to modify the xml in the database, is there another way to do it with just html or xml?

Xml

<?xml version="1.0" encoding="UTF-8"?>
<File>
<track type="General">
   <Format>MPEG-4</Format>
   <Codec_ID>mp42</Codec_ID>
   <Codec_ID>mp42 (mp42/mp41)</Codec_ID>
   <Tagged_date>UTC 2016-03-28 20:21:33</Tagged_date>
   <TIM>00:00:00:00</TIM>
   <TSC>60000</TSC>
   <TSZ>1001</TSZ>
</track>
</File>

Html

<span class="meta-label">  <?php echo $database['XML'] ?> </span> <span class="meta-content">Content</span></li>

Edit: This is a much more specific question than how to parse data, the other topic explains everything but it is not required to know all about XML to do some simple filtering. For people just looking on this specific question leaving it open would be better

Juanvulcano
  • 1,354
  • 3
  • 26
  • 44

1 Answers1

1

To answer to your question: No. Not possible with "just HTML or XML".

However I feel like simply answering your question does not really help you. Thus, here is a way you could handle this in PHP (since your question is tagged with the PHP tag as well): You could use the SimpleXMLElement class, to which constructor you can pass your XML, and then access is pretty simply, like so:

<?php
// caution, no valid XML in example!
$xmlElement = new SimpleXMLElement('<your><xml><here>'); 
echo $xmlElement->track[0]->Format
ArSeN
  • 5,133
  • 3
  • 19
  • 26