2,732
edits
Red Leader (talk | contribs) |
Red Leader (talk | contribs) (→Functions: Doc readxml()) |
||
Line 211: | Line 211: | ||
{{Nasal doc | {{Nasal doc | ||
|syntax = io.read_properties(path[, target]); | |syntax = io.read_properties(path[, target]); | ||
|text = Loads an XML file. Returns the data as a <code>props.Node</code> on success or <code>'''nil'''</code> on error. Note that the file ''must'' be in the [[PropertyList XML files|PropertyList]] format, or else the function will fail. | |text = Loads an XML file. Returns the data as a <code>props.Node</code> object on success or <code>'''nil'''</code> on error. Note that the file ''must'' be in the [[PropertyList XML files|PropertyList]] format, or else the function will fail. | ||
|param1 = path | |param1 = path | ||
|param1text = Path to the XML file as a string. | |param1text = Path to the XML file as a string. | ||
Line 255: | Line 255: | ||
=== readxml() === | === readxml() === | ||
Reads an XML file from an absolute path and returns it as | {{Nasal doc | ||
|syntax = io.readxml(path[, prefix]); | |||
|text = Reads an XML file from an absolute path and returns it as a <code>props.Node</code> object. All nodes will be of the string type. Also, all attributes will be converted in subnodes with a prefix appended. Returns <code>'''nil'''</code> on error. | |||
prefix | |param1 = path | ||
|param1text = Absolute path to the XML file. | |||
<syntaxhighlight lang=" | |param2 = prefix | ||
|param2text = Optional prefix to give to the attribute nodes. If it is <code>'''nil'''</code>, then attributes will be ignored. Defaults to "___" (three underscores). | |||
< | |example1text = First, put the following code into <tt>''[[$FG_HOME]]/Export/demo.xml''</tt>: | ||
< | <syntaxhighlight lang="xml"> | ||
<?xml version="1.0" encoding="UTF-8"?> | |||
<foo> | |||
<bar attr1="Hello" attr2="World">abc</bar> | |||
<bar>xyz</bar> | |||
</foo> | |||
</syntaxhighlight> | </syntaxhighlight> | ||
|example1 = var path = getprop("/sim/fg-home") ~ '/Export/demo.xml'; | |||
var data = io.readxml(path); | |||
props.dump(data); # dump data | |||
}} | |||
=== seek(filehandle, position, whence) === | === seek(filehandle, position, whence) === |