« Programmation Haxe/Haxe.xml » : différence entre les versions
Contenu supprimé Contenu ajouté
Ligne 107 :
// retourne -> "ClaTest.hx:22: Haxe<tmp><![CDATA[content]]></tmp>"
</source>
===attributes===
En partant de l'exemple 2
<source lang="haxe">
trace(x.attributes());
// retourne -> Main.hx:18: { next => #function:0, a => [where], p => 0, hasNext => #function:0 }
</source>
===elements===
<source lang="haxe">
package ;
class Main
{
static public function main()
{
var str = "<hello where=\"world\">Haxe<el>content_1</el><el>content_2</el></hello>";
// on parse le xml
var x : Xml = Xml.parse(str);
for (child in x.firstChild().elements())
{
trace(child.firstChild().nodeValue);
//
}
// retourne -> Main.hx:19: content_1
// Main.hx:19: content_2
}
}
</source>
===elementsNamed===
<source lang="haxe">
package ;
class Main
{
static public function main()
{
var str = "<hello where=\"world\">Haxe<el>content_1</el><el>content_2</el></hello>";
// on parse le xml
var x : Xml = Xml.parse(str);
for (child in x.firstChild().elements())
{
trace(child.firstChild().nodeValue);
//
}
// retourne -> Main.hx:19: content_1
// Main.hx:19: content_2
}
}
</source>
|