diff --git a/src/MicrodataPhpDOMElement.php b/src/MicrodataPhpDOMElement.php
index 58de31a..17e03b2 100644
--- a/src/MicrodataPhpDOMElement.php
+++ b/src/MicrodataPhpDOMElement.php
@@ -145,7 +145,11 @@ public function itemValue() {
if (!empty($datetime))
return $datetime;
default:
- return $this->textContent;
+ if ($this->getAttribute('content')) {
+ return $this->getAttribute('content');
+ } else {
+ return $this->textContent;
+ }
}
}
diff --git a/tests/data/recipe.html b/tests/data/recipe.html
new file mode 100644
index 0000000..717e7c7
--- /dev/null
+++ b/tests/data/recipe.html
@@ -0,0 +1,48 @@
+
+
+
+
+ recipe test
+
+
+
+
Mom's World Famous Banana Bread
+ By
John Smith,
+
+ May 8, 2009
+

+
This classic banana bread recipe comes
+ from my mom -- the walnuts add a nice texture and flavor to the banana
+ bread.
+ Prep Time:
+
+ 15 minutes
+ Cook time:
+
+ 1 hour
+ Yield:
1 loaf
+
+
+ Nutrition facts:
+ 240 calories,
+ 9 grams fat
+
+ Ingredients:
+ -
3 or 4 ripe bananas, smashed
+ -
1 egg
+ -
3/4 cup of sugar
+ ...
+ Instructions:
+
+ Preheat the oven to 350 degrees. Mix in the ingredients in a bowl. Add
+ the flour last. Pour the mixture into a loaf pan and bake for one hour.
+
+ 140 comments:
+
+ From Janel, May 5 -- thank you, great recipe!
+ ...
+
+
+
diff --git a/tests/data/recipeItempropContent.html b/tests/data/recipeItempropContent.html
new file mode 100644
index 0000000..4c11d98
--- /dev/null
+++ b/tests/data/recipeItempropContent.html
@@ -0,0 +1,59 @@
+
+
+
+
+ recipe itemprop content
+
+
+
+
+
+
+
+ recipe test
+
+
+
+
Mom's World Famous Banana Bread
+ By
John Smith,
+
+ May 8, 2009
+

+
This classic banana bread recipe comes
+ from my mom -- the walnuts add a nice texture and flavor to the banana
+ bread.
+ Prep Time:
+
1 hour, 10 minutes
+ Cook time:
+
15 minutes
+
+ Yield:
1 loaf
+
+
+ Nutrition facts:
+ 240 calories,
+ 9 grams fat
+
+ Ingredients:
+ -
3 or 4 ripe bananas, smashed
+ -
1 egg
+ -
3/4 cup of sugar
+ ...
+ Instructions:
+
+ Preheat the oven to 350 degrees. Mix in the ingredients in a bowl. Add
+ the flour last. Pour the mixture into a loaf pan and bake for one hour.
+
+ 140 comments:
+
+ From Janel, May 5 -- thank you, great recipe!
+ ...
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/src/MicrodataPhpTest.php b/tests/src/MicrodataPhpTest.php
index 817571a..6402174 100644
--- a/tests/src/MicrodataPhpTest.php
+++ b/tests/src/MicrodataPhpTest.php
@@ -47,6 +47,28 @@ public function testNestedItem() {
$this->assertEquals($address->properties['addressCountry'][0], "Germany", 'addressCountry property of nested item should be Germany.');
}
+ /**
+ * test recipe prep time
+ */
+ public function testRecipePrepTimeType() {
+ $config = $this->getConfig('recipe.html');
+ $microdata = new MicrodataPhp($config);
+ $data = $microdata->obj();
+
+ $this->assertEquals("PT15M", $data->items[0]->properties['prepTime'][0], 'recipe prepTime should be PT15M');
+ }
+
+ /**
+ * test recipe prep time
+ */
+ public function testRecipePrepTimeContentType() {
+ $config = $this->getConfig('recipeItempropContent.html');
+ $microdata = new MicrodataPhp($config);
+ $data = $microdata->obj();
+
+ $this->assertEquals("PT1H10M", $data->items[0]->properties['prepTime'][0], 'recipe prepTime should be PT1H10M');
+ }
+
/**
* @expectedException \InvalidArgumentException
*/