参考 getNum()

getNum()

Return an attribute's value as a Number.

The first parameter, name, is a string with the name of the attribute being checked. For example, calling myXML.getNum('id') returns the element's id attribute as a number.

The second parameter, defaultValue, is optional. If a number is passed, as in myXML.getNum('id', -1), it will be returned if the attribute doesn't exist or can't be converted to a number.

Note: Use myXML.getString() or myXML.getNum() to return an attribute's value.

示例

语法

getNum(name, [defaultValue])

参数

name

name of the attribute to be checked.

defaultValue

value to return if the attribute doesn't exist.

Notice any errors or typos? Please let us know. Please feel free to edit src/io/p5.XML.js and open a pull request!

相关参考