The MigrateXMLReader apparently can't handle XPaths with an infix attribute selector. For example:
/html/body/div[@id='storeArea']/div
Part of the problem is in line 706 of xml.inc where the regular expression uses a string boundary to find the attribute:
preg_match_all('|^\[@([^=]+)=[\'"](.*)[\'"]\]$|', $attribute_query, $matches);
Because of this, the remaining part of the XPath "[@id='storeArea']/div" does not match. Removing the string boundary is only part of the problem, as the above regular expression cannot match the remaining part of the path.
Comments
Comment #1
mikeryanAs documented, XMLReader does not handle the full xpath syntax - because we're not reading the entire XML into memory, the PHP xpath parsing isn't available to us, and it's not a goal to incorporate a full xpath parser in Migrate. Specialized use cases can always be addressed by overriding XMLReader, so I'm not inclined to put further effort into developing xpath parsing in Migrate itself.
Comment #2
chromix commentedWould it be possible to override XMLReader to use PHP's own xpath parsing? It's something I'd definitely like to do, and it sounds like it would solve a large part of what he's describing here. There are obvious drawbacks (like loading the XML into memory, obviously) but in many cases there may be no better option when real xpath parsing is required.