Path: C:\
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Busca de Produtos (SIMP)</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body { padding: 30px; background-color: #f8f9fa; }
</style>
</head>
<body>
<div class="container">
<h3 class="mb-4">🔍 Lista de Produtos - Sistema Siimp</h3>
<input type="text" id="searchInput" class="form-control mb-3" placeholder="Buscar por ..." onkeyup="filtrarProdutos()">
<table class="table table-bordered table-striped">
<thead class="table-dark">
<tr>
<th>Codigo</th>
<th>Nome</th>
<th>NCM</th>
<th>Perigoso</th>
<th>Policia_Civil</th>
<th>Policia_Federal</th>
<th>Exercito</th>
<th>Anvisa</th>
<th>Exportacao</th>
</tr>
</thead>
<tbody id="tabelaProdutos"></tbody>
</table>
</div>
<script>
let dadosXML = null;
fetch('produtos1.xml')
.then(response => response.text())
.then(xmlStr => (new window.DOMParser()).parseFromString(xmlStr, "text/xml"))
.then(data => {
dadosXML = data;
exibirLista(); // exibe os primeiros itens
});
function exibirLista(filtro = "") {
const itens = dadosXML.getElementsByTagName("item");
const tbody = document.getElementById("tabelaProdutos");
tbody.innerHTML = "";
let count = 0;
for (let i = 0; i < itens.length; i++) {
const codigo = itens[i].getElementsByTagName("codigo")[0].textContent;
const produto = itens[i].getElementsByTagName("nome")[0].textContent;
const ncm = itens[i].getElementsByTagName("ncm")[0].textContent;
const perigo = itens[i].getElementsByTagName("perigoso")[0].textContent;
const civil = itens[i].getElementsByTagName("policia_civil")[0].textContent;
const federal = itens[i].getElementsByTagName("policia_federal")[0].textContent;
const exercito = itens[i].getElementsByTagName("exercito")[0].textContent;
const anvisa = itens[i].getElementsByTagName("anvisa")[0].textContent;
const exportacao = itens[i].getElementsByTagName("exportacao")[0].textContent;
const texto = (produto + codigo).toLowerCase();
if (texto.includes(filtro.toLowerCase())) {
if (count < 50) {
tbody.innerHTML += `
<tr>
<td>${codigo}</td>
<td>${produto}</td>
<td>${ncm}</td>
<td>${perigo}</td>
<td>${civil}</td>
<td>${federal}</td>
<td>${exercito}</td>
<td>${anvisa}</td>
<td>${exportacao}</td>
</tr>
`;
count++;
}
}
}
if (count === 0) {
tbody.innerHTML = `<tr><td colspan="9" class="text-center">Nenhum produto encontrado.</td></tr>`;
}
}
function filtrarProdutos() {
const termo = document.getElementById("searchInput").value;
exibirLista(termo);
}
</script>
</body>
</html>