Closed BlacKCaT27 closed 7 years ago
For reference, I lucked into figuring this out. If you use "." for the element_name argument and speficy the attribute name as documented, you can retrieve the current element's attributes.
I would HIGHLY recommend this be added to the documentation.
Yes, that is definitely a missing feature that needs to be added, and I also agree that the documentation needs to be updated as well to document how XPath syntax like "." can be used with declxml.
After reading through the docs here:
http://declxml.readthedocs.io/en/latest/guide.html#attributes
I realized the error I was receiving earlier was due to me trying to read attributes as if they were elements.
However, the docs as linked above only show how to read an attribute from a child element to add an attribute to the parent. What if the element-in-question has no children?
Following the example code, say the XML looked like this:
How would one parse this xml with declxml such that the resulting output had "favoriteFood" with a value of pizza as an attribute of author?