Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sum and multiply #47

Open
roganov opened this issue Apr 11, 2020 · 0 comments
Open

Sum and multiply #47

roganov opened this issue Apr 11, 2020 · 0 comments
Labels

Comments

@roganov
Copy link

roganov commented Apr 11, 2020

Hello,

According to docs, sum and multiply is implemented, but I can't get this to work:

func main() {
	doc, err := xmlquery.Parse(strings.NewReader(`
<items>
    <item type="goods">
        <quantity unit="pcs">1</quantity>
        <unit-price currency="PLN">2</unit-price>
        <VAT>7</VAT>
    </item>
    <item type="goods">
        <quantity unit="pcs">10</quantity>
        <unit-price currency="PLN">20</unit-price>
        <VAT>7</VAT>
    </item>
    <item type="goods">
        <quantity unit="pcs">100</quantity>
        <unit-price currency="PLN">200</unit-price>
        <VAT>7</VAT>
    </item>
</items>
`))
	expr, err := xpath.Compile("sum(/items/item/(quantity * unit-price))")
	if err != nil {
		panic(err)
	}
	res := expr.Evaluate(xmlquery.CreateXPathNavigator(doc)).(float64)
	print(res)
}

This code panics with
panic: sum(/items/item/(quantity * unit-price)) has an invalid token

@zhengchun zhengchun added the bug label Apr 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants