Hallo Samuel,
So I better count with something like this:

wpt_pos=grep(XmlDump,'<wpt');
wpt_n=length(wpt_pos);

Thanks again, Jens
--------------------------------------------------

Am 06.06.2017 22:25, schrieb Samuel Gougeon:
Hello Jens,

Le 05/06/2017 à 02:12, Jens Simon Strom a écrit :
Hi,
Ex. 0 and 2 are o.k.. But what I want is Ex. 1.  What is wrong there?


//Ex. 0
doc = 
xmlRead("http://www.w3.org/TR/2009/REC-xml-names-20091208/xml-names-10-3e.xml";);
// Count the nodes with name equal to"note"
xp0 = xmlXPath(doc, "count(//note)")
xmlDelete(doc)

//Ex. 1
t=['<?xml version=""1.0"" encoding=""UTF-8"" standalone=""no""?>'+..
'<gpx xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""; xmlns=""http://www.topografix.com/GPX/1/1""; 
creator=""WTracks"" version=""1.1"" xsi:schemaLocation=""http://www.topografix.com/GPX/1/1 
http://www.topografix.com/GPX/1/1/gpx.xsd"";>'+..
'<wpt lat=""52.0"" lon=""8.0"">'+..
'<sym>City (Small)</sym>'+..
'</wpt>'+..
'</gpx>']
doc = xmlReadStr(t);
xmlDump(doc)
xp1 = xmlXPath(doc, "count(//wpt)")
xmlDelete(doc)

Apparently, the xmlns attribute (alone) is not supported out of the <?xml ?> initial header.
When we remove it, tags are counted as expected:

t=['<?xml version=""1.0"" encoding=""UTF-8"" standalone=""no""?>'+..
'<gpx xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""; creator=""WTracks"" version=""1.1"" '+.. ' xsi:schemaLocation=""http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"";>'+..
'<wpt lat=""52.0"" lon=""8.0"">'+..
'<sym>City (Small)</sym>'+..
'</wpt>'+.. '</gpx>'];
doc = xmlReadStr(t);
xp1 = xmlXPath(doc, "count(//wpt)")
xmlDelete(doc);

--> xp1 = xmlXPath(doc, "count(//wpt)")
 xp1  =
   1.

Since this attribute looks to be legal here (https://www.w3schools.com/xml/xml_namespaces.asp), the wrong result is likely a bug: http://bugzilla.scilab.org/enter_bug.cgi?product=Scilab software&component=XML

Best regards
Samuel Gougeon




_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users

Reply via email to