1.0.0 • Published 1 year ago

xml2treeconvertor v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Xml2Tree

Xml2Tree is a library for visualizing XML data in the browser as a tree using d3.js.

Demo: https://mmaltsev.github.io/Xml2Tree/

Docs: https://mmaltsev.github.io/Xml2Tree/docs/

Install

Add link to the library:

<script src="https://cdn.rawgit.com/mmaltsev/Xml2Tree/master/src/xml2tree.min.js"></script>

Create new div element:

<div class="chart1"></div>

Call function:

<script>
  xmltotree("chart1", "example/example.xml", [], false, false)
</script>

Options

VariableTypeDescription
elementIdstringid of div that contains tree.
filePathstringPath to the XML file.
secondLevelNodesarray of stringsList of nodes to show on second level of tree. Other will be contained in 'Extra'. If not specified - everything is shown.
isAttributesbooleanWhether to show all attributes of elements in XML or not.
isJSONbooleanSpecified when input file is JSON.

Examples

You can find an XML file that is used below here.

1 Example Code:

<script>
  var elementId = 'chart1';
  var filePath = 'example/example.xml';
  var secondLevelNodes = [];
  var isAttributes = true;
  var isJSON = false;
		
  xml2tree(elementId, filePath, secondLevelNodes, isAttributes, isJSON);
</script>

1 Example Result:

2 Example Code:

<script>
  var elementId = 'chart1';
  var filePath = 'example/example.xml';
  var secondLevelNodes = ['book'];
  var isAttributes = false;
  var isJSON = false;
		
  xml2tree(elementId, filePath, secondLevelNodes, isAttributes, isJSON);
</script>

2 Example Result:

License.

MIT License. Copyright (c) 2016-2017 Maxim Maltsev.

1.0.0

1 year ago