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

In XSLT, is it possible to have a pointer to a function?
XPath 3.0 compare dates diffrence with duration literal
Unable to debug “xpath is invalid”
Does Yahoo Company News RSS Link have Limited Query Parameters
XML-log to chart
How to use URL from server that is url encoded in XML
Parsing an XML document from a decrypted string
Generic way to use XSLT to generate text from one “template” XML and another “arguments” XML
JAXB Marshallingremove namespace prefix
Get Max Value Attribut Using XPATH JDom
read and concatenate xml attributes using shell script
XML Schema not working after Vendor added Fields
XML Parsing Error: not well formed location : chrome
Parse for attribute in xml namespace with element tree
Hibernate Inheritance mapping with an interface parent
Is send_resp() and put_resp_content_type() the canonical way to send a string as XML in Phoenix?

Categories

HOME
go
deep-learning
developer-tools
apache-jena
angular-formly
swt
interface
pascal
fftw
jsf-2.2
pdfbox
bitbucket-api
gembox-spreadsheet
ado.net
webix
lanczos
special-characters
computer-science
mod-security
alamofire
selenium-ide
gource
eip
do-while
altera
google-data-studio
google-picker
git-extensions
smartclient
inno-download-plugin
interpreter
xunit
maze
ms-access-web-app
browser-sync
tizen-tv
send
livelink
python-2.6
turfjs
jbutton
hibernate-validator
rselenium
slacktextviewcontroller
docfx
dm-script
modernizr
health-monitoring
urlsession
news
comparison-operators
odoo-website
flask-restful
openresty
magento-2.0.7
user-defined-fields
identification
openblas
backbone-collections
restore
testrail
visual-studio-2008-sp1
atlas
microstation
xcode-server
drawstring
cifilter
simevents
maybe
grgit
oracle-spatial
sony-lifelog-api
teamcity-9.1
zxspectrum
xmltype
adehabitathr
beatsmusic
uncaught-typeerror
iiop
primitive-types
encryption-asymmetric
lambda-architecture
ss7
decoupling
amslidemenu
inputmismatchexception
away3d
oocss
workitem
octal
diem
windows-98
extreme-programming
httponly
kqueue
pinch
xcelsius
mysql-error-1205
jqote
instantiationexception
binomial-heap
silverlight-oob
lobo-cobra
tui
xpsdocument
java1.4
wspbuilder

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