Author Topic: {RESOLVED} approach to parsing product_attributes for line item  (Read 2715 times)

swheeler

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 9
Hi,

<span class="costumTitle">Size</span><span class="costumValue" >Medium</span>

This is actually the text representation component of a VirtueMart order line that is stored in JSON array format in 'product_attributes' column in the 'order_items' table.  I am attempting to parse out the value of 'Medium' for the 'costumValue' class.  So far, I've been using the following code without any success:

       $dom = $dom = new DOMDocument();
                     
              $dom->load($val);      // where $val is the text represented above.
              $finder = new DomXPath($dom);
              $classname = "costumValue";
              $nodes = $finder->query("//*[contains(@class, '$classname')]");
              //echo $nodes->item(0)->nodeValue . "\n";
              //echo $nodes->nodeValue . "\n";
              echo $nodes->childNodes . "\n";

Any recommendations?

Thanks,
Scott