Skip to main content

Hello,

I am using XML updater to update geodatabase metadata and it works well with single tag value.

However when there are multiple tags it updates all of them with the same value.

XML path in XMLUpdater: dataIdInfo/tpCat/TopicCatCd – before the change

<tpCat>

<TopicCatCd value="007"></TopicCatCd>

</tpCat>

<tpCat>

<TopicCatCd value="018"></TopicCatCd>

</tpCat>

XML path in XMLUpdater: dataIdInfo/tpCat/TopicCatCd, change value: 44 – after the change

<tpCat>

<TopicCatCd value="44"></TopicCatCd>

</tpCat>

<tpCat>

<TopicCatCd value="44"></TopicCatCd>

</tpCat>

Expected results after the change

<tpCat>

<TopicCatCd value="44"></TopicCatCd>

</tpCat>

<tpCat>

<TopicCatCd value="018"></TopicCatCd>

</tpCat>

 

Any help much appreciated.

 

Many thanks

Magda

Do you only want to update the first tag, or only update where the value = 007?


Hello ebygomm,

Many thanks for looking into the question.

I would like to know how to access/update first, second, third etc. tag. For example, if I want to update the 007 value, essentially this means I want to update the first tag. How do I go about it?


If you want to update the first tag you can use

//tpCat/TopicCatCd[1]

 

If you want to update the tag with value 007 you can use

//tpCat/TopicCatCdd@value = '007']


Many thanks ebygomm, that is what I was looking for, much appreciated!

Do you know how I can add a tag with a value?

Many thanks,

Magda


If you want to update the first tag you can use

//tpCat/TopicCatCd[1]

 

If you want to update the tag with value 007 you can use

//tpCat/TopicCatCdd@value = '007']

It does not work if I try to delete by value. Is there a different statement for deleting by value?


I normally use the XMLXQueryUpdater for updating xml and would use something like this to delete a node

e.g.

for $node in //TopicCatCd
where $nodet@value="007"]
return delete node $node

 


Reply