mercredi 1 décembre 2021

Need values from XML depending on choosed option

<select class="xml-data-select"><option value="">Choose XML Heading</option><option value="Products > Product > SKU">Products &gt; Product &gt; SKU</option><option value="Products > Product > Name">Products &gt; Product &gt; Name</option><option value="Products > Product > LongDescription">Products &gt; Product &gt; LongDescription</option><option value="Products > Product > Quantity">Products &gt; Product &gt; Quantity</option><option value="Products > Product > BuyPrice">Products &gt; Product &gt; BuyPrice</option><option value="Products > Product > Price">Products &gt; Product &gt; Price</option><option value="Products > Product > SalePrice">Products &gt; Product &gt; SalePrice</option></select>

I have this dropdown option, after choosing an option I have to fetch the values from the XML file. Suppose if I choose "Products > Product > LongDescription" then fetch all the values of "LongDescription" from the XML file like following

array (
   0=>'Don't forget me this weekend!',
   1=>null,
   2=>null,
   3=>'Test description'
)

XML File

<?xml version="1.0" encoding="UTF-8"?>
<Products>
  <Product>
    <SKU>RR02</SKU>
    <Name>Samsung Cable for QLED TVs, 15m</Name>
    <ShortDescription></ShortDescription>
    <LongDescription>Don't forget me this weekend!</LongDescription>
    <Quantity>10</Quantity>
    <BuyPrice>8</BuyPrice>
    <Price>10</Price>
    <SalePrice>9</SalePrice>
  </Product>
  <Product>
    <SKU>ITEM-000249</SKU>
    <Name>71T6550</Name>
    <ShortDescription></ShortDescription>
    <LongDescription></LongDescription>
    <Quantity>0</Quantity>
    <BuyPrice>0</BuyPrice>
    <Price>0</Price>
    <SalePrice>0</SalePrice>
  </Product>
  <Product>
    <SKU>ITEM-1</SKU>
    <Name></Name>
    <ShortDescription></ShortDescription>
    <LongDescription></LongDescription>
    <Quantity>0</Quantity>
    <BuyPrice>0</BuyPrice>
    <Price>0</Price>
    <SalePrice>0</SalePrice>
  </Product>
  <Product>
    <SKU>ITEM-2</SKU>
    <Name></Name>
    <ShortDescription></ShortDescription>
    <LongDescription></LongDescription>
    <Quantity>3</Quantity>
    <BuyPrice>15</BuyPrice>
    <Price>20</Price>
    <SalePrice>18</SalePrice>
  </Product>
</Products>


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire