xml


Matlab: read XML with multiple of childs?


Here my 'C1.xml' file:
<!DOCTYPE GroundTruth>
<dataset name="camera1">
<frame number="00000000"/>
<frame number="00000001"/>
<frame number="00000002"/>
<frame number="00000003"/>
<frame number="00000004"/>
.
.
.
<frame number="00000233">
<person id="0001">
<leftEye x="626" y="210"/>
<rightEye x="643" y="214"/>
</person>
</frame>
<frame number="00000234">
<person id="0003">
<leftEye x="619" y="211"/>
<rightEye x="636" y="215"/>
</person>
</frame>
<frame number="00000235">
<person id="0025">
<leftEye x="613" y="213"/>
<rightEye x="630" y="216"/>
</person>
</frame>
<frame number="00004403"/>
<frame number="00004404"/>
<frame number="00004405"/>
<frame number="00004406"/>
<frame number="00004407"/>
<frame number="00004408"/>
<frame number="00004409"/>
</dataset>
My incomplete code:
xDoc = xmlread('C1.xml');
allListitems = xDoc.getElementsByTagName('frame');
frameL = allListitems.getLength;
for k = 0:frameL-1
thisElement = allListitems.item(k);
thisList = thisElement.getElementsByTagName('person');
if (thisList.getLength~=0)
thisElement = thisList.item(0);
% problem is here where I also don't know what type of data findCbk
% have (char or ...??)
findCbk = char(thisElement.getFirstChild.getData);
end
end
I want to get the frame number with corresponding person id and the data for leftEye and rightEye. So, if I sprintf findCbk, it will give me numbers that I can't relate for %d and empty for %s.
So here the answer. The thing that I need is getAttribute. So I write down the code if someone having the same problem or if someone can correct me if I was wrong.
xDoc = xmlread('C1.xml');
allListitems = xDoc.getElementsByTagName('frame');
frameL = allListitems.getLength;
for k = 0: frameL-1
thisElement = allListitems.item(k);
frameNum = (char(thisElement.getAttribute('number')))
%check the child inside element frame
thisList = thisElement.getElementsByTagName('person');
face = thisList.getLength;
if (face~=0)
thisElement = thisList.item(0);
personID = (char(thisElement.getAttribute('id')))
eyeL = thisElement.getElementsByTagName('leftEye');
thisElementl = eyeL.item(0);
xL = (char(thisElementl.getAttribute('x')))
yL = (char(thisElementl.getAttribute('y')))
eyeR = thisElement.getElementsByTagName('rightEye');
thisElementr = eyeR.item(0);
xR = (char(thisElementr.getAttribute('x')))
yR = (char(thisElementr.getAttribute('y')))
break
end
end
It will return:
frameNum =
00000000
frameNum =
00000001
frameNum =
00000002
.
.
.
.
frameNum =
00000230
frameNum =
00000231
frameNum =
00000232
frameNum =
00000233
personID =
0003
xL =
626
yL =
210
xR =
643
yR =
214

Related Links

Data mashups in R: “subscript out of bounds”
Updating a XML file using Qt DOM
Add new node with attribiutes to xml file
Select xml element value in Oracle
How to get value of XML element containing a namespace prefix using XDocument?
Call XML items through flash based on date
Creating an XML file using Schema
Automated comparison of XML files?
Combining Sibling XML Tags
Reading xml with partial whitespace
Check for empty XML element using XSLT
Create custom section tree from .sitemap file
xsl prints child nodes on the line below where I want it
XSLT Concat fields together
QXmlStreamReader count entries
Simplest way of outputting a single XML tag into HTML tag

Categories

HOME
shell
windows
gridview
scikit-learn
facebook-oauth
codenvy
redux-form
phpmyadmin
twig
components
oracle-apex-5
graphics
solver
simulink
mips
hpc
python-multithreading
jtextpane
lanczos
little-proxy
resultset
ipmitool
openbugs
frequency-distribution
alpacajs
scsi
google-container-registry
sencha-touch
oledb
tosca
displaytag
perlbrew
google-cloud-print
outliers
linked-data
gp
jaws
calculation
aws-codecommit
git-squash
playstation-portable
android-maps-extensions
nested-lists
modalviewcontroller
baidu-map
sim-toolkit
magento-1.9.2.4
projects-and-solutions
typesafe-config
odoo-website
subclipse
apache-spark-dataset
flask-login
gitlist
reportservice2010
qtranslate
cup
bbpress
d3-force-directed
ampps
materialized-path-pattern
actor-platform
pacemaker
avspeechsynthesizer
pre-build-event
false-sharing
realsense
inf
grgit
computer-architecture
poppler
binomial-theorem
zscript
rdflib
ms-access-2000
fits
dot.js
cryptographichashfunction
dbaccess
nodelist
post-commit-hook
jama
cancellation
mutual-authentication
git-repo
away3d
windows-phone-8-sdk
inappsettingskit
process-explorer
intersect
android-loadermanager
qi4j
cross-database
stress
jqote
uipagecontrol
clrstoredprocedure
squishit
timertask
silverlight-oob
xpsdocument
firefox-3
pbcopy

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App