dingodart 1.0.0 copy "dingodart: ^1.0.0" to clipboard
dingodart: ^1.0.0 copied to clipboard

Parser and DOM for the Dingo markup language in Dart

example/main.dart

import 'dart:io';
import '../lib/dingodart.dart';

void main(List<String> arguments) async {
	// parse ./test.dml
	var doc = parseDocument(await File("./test.dml").readAsString());

	// create new tag called <blegh>
	var node = TagNode("blegh");
	node["attribute"] = "value";
	// create two text nodes (one cdata, to demonstrate the different text spacing rules)
	node.appendChild(TextNode("weirdly\nspaced\nstring"));
	node.appendChild(CdataNode("weirdly\nspaced\nstring"));
	// add to document
	doc.appendChild(node);

	// note that if there is no <embryo/> this section will fail silently

	// find <egg> containing <embryo> -- this is an example of the 'query' system
	var egg = doc.findTag((e) => e.nameIs("egg").hasChildWhere((e) => e.nameIs("embryo")));
	
	// rename embryo to chick
	var chick = egg?.findByName("embryo");
	chick?.name = "chick";

	// create and add brain
	var brain = TagNode("brain");
	brain["size"] = "small";
	chick?.appendChild(brain);

	// print updated source
	print(doc.outerSource());
}
0
likes
150
points
41
downloads

Publisher

unverified uploader

Weekly Downloads

Parser and DOM for the Dingo markup language in Dart

Repository

Documentation

API reference

License

BSD-2-Clause (license)

More

Packages that depend on dingodart