2

This is my xml file:

<?xml version="1.0" encoding="UTF-8"?>
<XMLConverter> 
<Positions> 
   <Side0 Chemin="face.jpg"/>
   <Side1 Chemin="droite1.jpg"/>
   <Side2 Chemin=""/> 
   <Side3 Chemin=""/> 
   <Side4 Chemin="dos.jpg"> 
       <Dos28 PositionY="0.906845" PositionX="0.602489" Nom="Dos28" NoSelect="0"/>
       <Dos29 PositionY="0.910139" PositionX="0.570278" Nom="Dos29" NoSelect="0"/> 
       <Dos26 PositionY="0.93869" PositionX="0.601025" Nom="Dos26" NoSelect="0"/> 
   </Side4> 
   <Side5 Chemin="gauche1.jpg"/> 
   <Side6 Chemin="gauche2.jpg"/> 
   <Side7 Chemin=""/> 
</Positions> 
<Marqueurs>
<Angles>
<Distances>
</XMLConverter>

I want to change the value of PositionY in Dos28.

I have tried this:

r=num2str(25);
xDoc=xmlread(fullfile(('test pour zones.xml')));
allListItems=xDoc.getElementsByTagName('Side4');
allListItems=allListItems.item(0);
thisListItem=allListItems.getElementsByTagName('Dos28');
thisListItem.setAttribute('PositionY','25');
xmlwrite('test pour zones2.xml',xDoc);

I have a error in Matlab: ??? No appropriate method, property, or field setAttribute for class org.apache.xerces.dom.DeepNodeListImpl.

Thanks for help!

1 Answer 1

1

Even though matlab only finds a single element with element name 'Dos28' it still returns a list. You still need to get the first item from the list.

thisListItem=allListItems.getElementsByTagName('Dos28');
thisListItem=thisListItem.item(0);
thisListItem.setAttribute('PositionY','25');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.