Code Monkey home page Code Monkey logo

xml-reader's Introduction

XML Reader

⚙️ Installation

Installation is done using the boss install command line:

boss install viniciussanchez/xml-reader

⚙️ Manual Installation for Delphi

If you choose to install manually, simply add the following folders to your project, in Project > Options > Resource Compiler > Directories and Conditionals > Include file search path

../xml-reader/src

⚡️ Quickstart

uses Xml.Reader;

Load from file

var
  LXmlReader: IXmlReader;
begin
  LXmlReader := TXmlReader.New.LoadFromFile('C:\xml\nfe.xml');
end;

Load from string

var
  LXmlReader: IXmlReader;
begin
  LXmlReader := TXmlReader.New.LoadFromString('my xml here!');
end;

Get xml version

begin
  Result := LXmlReader.Version;
end;

Get xml encoding

begin
  Result := LXmlReader.Encoding;
end;

Get main node

var
  LMainNode: IXmlNode;
begin
  LMainNode := LXmlReader.Node;
end;

How to list nodes

var
  LNode: IXmlNode;
begin
  for LNode in LMainNode.Nodes do
    // my code here!
end;

How to list attributes

var
  LAttribute: IXmlAttribute;
begin
  for LAttribute in LMainNode.Attributes do
    // my code here!
end;

How to list elements

var
  LElement: IXmlElement;
begin
  for LElement in LMainNode.Elements do
    // my code here!
end;

Other resources

var
  LNode: IXmlNode;
  LElement: IXmlElement;
  LAttribute: IXmlAttribute;
begin
  // get the name of a node
  LNode.Name;

  // check if the node has an attribute
  LNode.ContainsAttribute('attribute name');

  // check if the node has a node
  LNode.ContainsNode('node name');

  // check if the node has an element
  LNode.ContainsElement('element name');    

  // get the value of an attribute from a node
  LNode.GetAttribute('attribute name');

  // get a node from a node
  LNode.GetNode('node name');

  // get the element of a node
  LNode.GetElement('element name');

  // get the attributes of a node
  LNode.Attributes;

  // get the elements of a node
  LNode.Elements;

  // get the nodes of a node
  LNode.Nodes;

  // get the name of an element
  LElement.Name;

  // get the value of an element
  LElement.Value;  

  // get the value in string format from an element
  LElement.AsString;

  // get the value in integer format of an element
  LElement.AsInteger;

  // get the name of an attribute
  LAttribute.Name;

  // get the value of an attribute
  LAttribute.Value;  

  // get the value in string format of an attribute
  LAttribute.AsString;

  // get the value in integer format of an attribute
  LAttribute.AsInteger;
end;

⚠️ License

XML Reader is free and open-source software licensed under the MIT License.

xml-reader's People

Contributors

viniciussanchez avatar jtheiller avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.