I'm hoping someone can lead me in the right direction with this. I'm using xpath to get an xml document that is stored in a sql database. What I'm getting looks something like:
<root>
<parent valuea="something" valueb="something">
<child valuec="something" valued="something" />
</parent>
</root>
What I'm trying to do is change valuea from "something" to "somethingelse". I tried using setAttribute but had no success with it. I think I'm missing something on how to point it to the right element. It's putting the updated attribute in <root> not <parent>.
I also tried using appendChild. That did not work because it removes <child> as well as all the other attributes in <parent>. I have no way of knowing ahead of time what's contained in the parent or child elements. If anybody could lead me in the correct direction on how to do this I would appreciate it.I Figured it out. My XML was not compliant. I did end up using something like $VDom->documentElement->setAttribute($AttributeName,$AttributeValue); after fixing the XML.
<root>
<parent valuea="something" valueb="something">
<child valuec="something" valued="something" />
</parent>
</root>
What I'm trying to do is change valuea from "something" to "somethingelse". I tried using setAttribute but had no success with it. I think I'm missing something on how to point it to the right element. It's putting the updated attribute in <root> not <parent>.
I also tried using appendChild. That did not work because it removes <child> as well as all the other attributes in <parent>. I have no way of knowing ahead of time what's contained in the parent or child elements. If anybody could lead me in the correct direction on how to do this I would appreciate it.I Figured it out. My XML was not compliant. I did end up using something like $VDom->documentElement->setAttribute($AttributeName,$AttributeValue); after fixing the XML.