Skip to content

Parsed XPATH value as variable of user function #1

@seirerman

Description

@seirerman

Not sure if this is a bug, works-as-designed:

I'm trying to parse an xml file which includes, among other things, a string containing a ISO 8601 datetime string ("2017-12-07T07:30:00+01:00").

I can parse that with cobj_xpath just fine. But since this isn't the format I want on the website, I need to transform it into epoch format so that stdWrap can use strftime.

So I wrote a small user function that does exactly that.
But attaching the XPATH object as a variable to the user function returns only "0".
It works if I send a static date string to the user function.

I did some var_dumping in the user function ("var_dump($conf);") and saw that $conf had all the config of the xpath object, but not the parsed string.

lib.xpath {
	source = https://lawine.tirol.gv.at/rest/bulletin/latest/xml/de
	return = string
	expression = caaml:metaDataProperty//caaml:MetaData//caaml:dateTimeReport
	resultObj {
		cObjNum = 1
		1.current = 1
	}
}

lib.datetime= USER
lib.datetime{
	userFunc = user_functions->iso8601toUnixTimestamp
# Static value works
#	iso8601 = 2017-12-07T07:30:00+01:00
# XPATH doesn't work
	iso8601 < lib.xpath 
}

Any idea if this is possible, or what's wrong with my code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions