What causes this inconsistency in xml parsing?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Nathan Jessurun
el 9 de Jul. de 2018
Respondida: Nathan Jessurun
el 17 de Jul. de 2018
I have the following XML file:
<?xml version="1.0" encoding="utf-8"?>
<AddressBook>
<Entry>
<Name>Friendly J. Mathworker</Name>
<PhoneNumber>(508) 647-7000</PhoneNumber>
<Address hasZip="no" type="work">3 Apple Hill Dr, Natick MA</Address>
</Entry>
<Entry>
<Name>Joe P. Surname</Name>
<PhoneNumber>(334) 647-8898</PhoneNumber>
<Address hasZip="no" type="work">123 Addr Lane, Chicago NY</Address>
</Entry>
<Entry>
<Name>Mary Sue Lastname</Name>
<PhoneNumber>(508) 552-5698</PhoneNumber>
<Address hasZip="no" type="home">456 Another Addr, Boston OR</Address>
</Entry>
</AddressBook>
Which I capture in DOM form with
dom = xmlread(file)
xmlEl = dom.getDocumentElement();
There should be 3 first-level children, correct? But when I call
xmlEl.getLength();
the answer is 7!
It gets better: I then call
xmlwrite(dom);
After which xmlEl.getLength returns 3! What is happening here? Any help would be appreciated
4 comentarios
Guillaume
el 9 de Jul. de 2018
xml2struct seems to be able to handle that properly. From reading the code, it would appear that it just discards these #text empty children.
Respuesta aceptada
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!