What you are being part of the concepts used in a REST API. See here
Backend is in charge of managing and providing the data in a practical format like json, from there, the responsibility of displaying this data is the application of Frontend ( or other backend in case of Microservices).
An example with jQuery:
var objetoJS = jQuery.parseJSON(jsonDoServidor)
jsonDoServidor
is what was generated by your json_encode(simplexml_load_string($show));
Note: This should be routed to your JS in some way, either via common http (in the API Routes style) or even in rendering (not the best practice anymore works).
If you are going to do it via rendering, when your PHP generates HTML, you can do something by embedding PHP into JS. Example:
index.html
<script>
var jsonDoServidor = jQuery.parseJSON(
<?php echo json_encode(simplexml_load_string($show)); ?>
)
console.log(jsonDoServidor)
</script>
Note that your PHP is creating jsonDoServidor dynamically to be used by JS.
This works, however, perhaps not the best practice.
A better alternative is to create a file/route that returns only JSON and, through an ajax call, take this content and use it.
$.get("/linkproJson").done(function(data){
console.log(data)
var jsonDoServidor = jQuery.parseJSON(data)
});
No matter how you do it, you get the data in a ready-to-use Obj on JS.
I tried to explain based on what I understood, but your question was not so direct.
To help you come up with ideas, see what I have similar to your need (I use this with Laravel, so PHP tags are simplified but the concept is the same):
// Recebe o Json para a view
produtos = {!! $analises->produtos or $analisesProdutos !!}
// Pega a tabela
var tableRef = document.getElementById('analisesProdutos-table').getElementsByTagName('tbody')[0];
// Cria as linhas na tabela com os dados que vieram do Servidor
produtos.forEach(function (item) {
var newRow = tableRef.insertRow(item);
newRow.innerHTML = `
<td><a href="/analisesProdutos/${item.id_mlb}">${item.id_mlb}</a></td>
<td>${item.seller_mlb}</td>
<td>${item.name}</td>
<td>${item.price}</td>
<td>${item.sold_on_register}</td>
<td id='${item.id_mlb}-sold_last'></td>
<td></td>
`
})
Supplement your question with the full code
– Gabriel Carvalho