I have the following DOMNodeList Object being returned from Google and I need to parse through it.
I am parsing it into an array of DOMElement Objects, one for each warning with:
$new_product = _GSC_AtomParser::parse($resp->body);
$elements = $new_product->getWarnings();
$warnings = array();
foreach ($elements as $element):
$warnings[] = $element;
endforeach;
Then I need to parse these DOMElement Objects to get the warnings:
[0] => DOMElement Object
(
[tagName] => sc:warning
[schemaTypeInfo] =>
[nodeName] => sc:warning
[nodeValue] => validation/missing_recommendedShoppinggoogle_product_categoryWe recommend including this attribute.
[nodeType] => 1
[parentNode] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] =>
[nextSibling] => (object value omitted)
[attributes] => (object value omitted)
[ownerDocument] => (object value omitted)
[namespaceURI] => http://schemas.google.com/structuredcontent/2009
[prefix] => sc
[localName] => warning
[baseURI] => /home/digit106/dev/public_html/manager/
[textContent] => validation/missing_recommendedShoppinggoogle_product_categoryWe recommend including this attribute.
)
I want to format this into an array like so:
[warnings] => Array
(
[0] => Array
(
[domain] => Shopping
[code] => validation/missing_recommended
[location] => google_product_category
[internalReason] => We recommend including this attribute.
)
)
But all that data seems to be nested into either the nodeValue or textContent.
How the heck do I parse this out?
Did you try the PHP DOMNodeList class ?
Regards?