Matlab xml parsing delivers empty elements -


i have xml file following structure

<?xml version='1.0' encoding='us-ascii'?>  <config_paramters name="model">   <joint name = "number_1">     <parameter>       <joint param = "minnumber1"   value = "-1*m_pi/180" units = "in rad" desc = "max ang 1"/>       <joint param = "maxnumber1"   value = "-2*m_pi/180" units = "in rad" desc = "min ang 1"/>     </parameter>   </joint>   <joint name = "number_2">     <parameter>       <joint param = "minnumber2"   value = "1*m_pi/180" units = "in rad" desc = "max ang 2"/>       <joint param = "maxnumber2"   value = "0*m_pi/180" units = "in rad" desc = "min ang 2" />     </parameter>   </joint> </config_paramters> 

and access nodes, following code returns empty elements:

filename = 'settings.xml'; xdoc = xmlread(filename); nodelist = xdoc.getelementsbytagname('joint'); firstnode = nodelist.item(0) firstnodecontent = firstnode.gettextcontent 

shouldn't 1 work? great if tell me problem.

your problem have no text content inside 'joint' nodes, other nodes, .gettextcontent returns nothing. text content this:

<?xml version='1.0' encoding='us-ascii'?>  <config_paramters name="model">   <joint name = "number_1">     hello   </joint>   <joint name = "number_2">     world!   </joint> </config_paramters> 

if you're going structure xml in question, you'll need continue extracting individual nodes , attributes needed. might interested in various solution on mathworks' file exchange convert xml file matlab struct, e.g., this , this – both called xml2struct. if have bioinformatics toolbox, there little-documented function of name included that.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -