0

I have the following XML file contents:

<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:noNamespaceSchemaLocation="Vini.xsd" generated="2012-07-24T17:35:00">
<Vini>
<ID>1</ID>
<Provincia>BG</Provincia>
<Produttore>ANGELO PECIS</Produttore>
<Nome>VALCALEPIO MOSCATO PASSITO ARGO</Nome>
</Vini>
<Vini>
<ID>2</ID>
<Provincia>BG</Provincia>
<Produttore>ANGELO PECIS</Produttore>
<Nome>VALCALEPIO ROSSO RISERVA ROSSO DELLA PEZIA</Nome>
</Vini>
...
<dataroot>

when I tried to parse XML

...
var xmlStr = new XML ( fileContents);
var str = xmlStr.xpath("//Vini");
len = str.length()

number of Vinis (len) is 0. Why?

1 Answers1

0

The xpath expression looks good. I also made a concluant test here. Question is, are you sure your xml is well instantiated ?

I would look at the file contents object and then the XML object itself. Maybe one of both failed to initialize. I don't know the context but If you do use ExtendScript ToolKit, it fails on big xml files and fails to load the XML object.

If that so, try on a smaller chunk of XML and see if it's better.

Loic
  • 2,173
  • 10
  • 13