Search code examples
xmlxpathxqueryxquery-sqlxqilla

complex XML XQUERY invalid content after root element's end tag [err:FODC0002]


1.Alexa API response about google.com: http://pastebin.com/C5yjSjCf -in other words it is representing one row from 12 simple tables called "ContactInfo" "Rank by Country", ...

and just one more example (facebook.com) http://pastebin.com/mP813jYS

2.Scheme/data type information: http://awis.amazonaws.com/AWSAlexa/AWSAlexa.xsd

i can do basic xquery with xqilla

query.txt:

declare namespace aws="http://alexa.com";

/aws:UrlInfoResponse/aws:Response/aws:UrlInfoResult/aws:Alexa/aws:ContentData/aws:DataUrl

xqilla -i alexa.xml query.txt
Error parsing resource: file:///var/www/google  Error message: invalid content after root element's end tag [err:FODC0002]

xqilla -i google.xml query.txt
Error parsing resource: file:///var/www/Error message: invalid content after root element's end tag [err:FODC0002]

alexa.xml (the file i want to query actually), is many of these api responses after eachother

i also tried deleting the first 3 lines and the last one from google.xml and to search&replace aws:' and leading spaces , jsut to make it more simple but still the same Error :(


Solution

  • You said...

    alexa.xml (the file i want to query actually), is many of these api responses after eachother

    Is this what it sounds like? Does your file look something like this?

    <aws:UrlInfoResponse xmlns:aws="http://alexa.com">
        <!--...-->    
    </aws:UrlInfoResponse>
    <aws:UrlInfoResponse xmlns:aws="http://alexa.com">
        <!--...-->    
    </aws:UrlInfoResponse>
    

    That would also explain your error. You're only allowed to have one root element. You'd need to wrap it all in another element.

    Example:

    <responses>
        <aws:UrlInfoResponse xmlns:aws="http://alexa.com">
            <!--...-->    
        </aws:UrlInfoResponse>
        <aws:UrlInfoResponse xmlns:aws="http://alexa.com">
            <!--...-->    
        </aws:UrlInfoResponse>    
    </responses>
    

    XPath:

    /responses/aws:UrlInfoResponse/aws:Response/aws:UrlInfoResult/aws:Alexa/aws:ContentData/aws:DataUrl