Quantcast
Channel: Elmax
Viewing all articles
Browse latest Browse all 37

Updated Wiki: Home

$
0
0
Project Description
Yet another easy to use C++ and C# XML parser library on Windows platform!

Portable Elmax is ready!!! Download at https://sourceforge.net/projects/elmax/

The code to create a simple XML, using C++ Elmax
usingnamespace Elmax;

Element root;
root.SetDomDoc(pDoc); // A empty DOM doc is initialized beforehand.
root[L"Books|Book|Price"].SetFloat(12.99f);

The almost similar code to create a simple XML, using C# Elmax
using Elmax;

Element root = new Element();
root.SetDomDoc(doc); // A empty DOM doc is initialized beforehand.
root["Books|Book|Price"].SetFloat(12.99f);

The end result (XML)
<Books><Book><Price>12.990000</Price></Book></Books>


The C++ code to read the price in that XML
usingnamespace Elmax;

Element root;
root.SetDomDoc(pDoc); // A XML file is read into the DOM doc beforehand.
Element elemPrice = root[L"Books|Book|Price"];
if(elemPrice.Exists())
{
    float price = elemPrice.GetFloat(10.0f);
}

The similar C# code to read the price in that XML
using Elmax;

Element root = new Element();
root.SetDomDoc(doc); // A XML file is read into the DOM doc beforehand.
Element elemPrice = root["Books|Book|Price"];
if(elemPrice.Exists)
{
    float price = elemPrice.GetFloat(10.0f);
}

An code example of Linq-to-XML Style of Node Creation in version 0.82 of C++ Elmax
usingnamespace Elmax;

NewElement root(L"Foods");

root.Add(
    NewElement(L"Food",
        NewAttribute(L"Name", L"Luncheon Meat"),
        NewAttribute(L"Price", L"8.40"),
        NewAttribute(L"Category", L"Grocery"),
        NewElement(L"Manufacturer",
            NewElement(L"Address", L"Jurong, Singapore"),
            NewElement(L"Name", L"Acme Canned Food")
        )
    ),
    NewElement(L"Food",
        NewAttribute(L"Name", L"Instant Noodle"),
        NewAttribute(L"Price", L"12.30"),
        NewAttribute(L"Category", L"Dried Food"),
        NewElement(L"Manufacturer",
            NewElement(L"Address", L"Ang Mo Kio, Singapore"),
            NewElement(L"Name", L"Ah Kong Food Industrial")
        )
    )
);

root.PrettySave(szPath, L"1.0", true);

Here is the XML contents generated from the above Linq-to-XML Style of Node Creation code.
<?xmlversion="1.0"encoding="UTF-8"?><Foods><FoodName="Luncheon Meat"Price="8.40"Category="Grocery"><Manufacturer><Address>Jurong, Singapore</Address><Name>Acme Canned Food</Name></Manufacturer></Food><FoodName="Instant Noodle"Price="12.30"Category="Dried Food"><Manufacturer><Address>Ang Mo Kio, Singapore</Address><Name>Ah Kong Food Industrial</Name></Manufacturer></Food></Foods>

Tutorial at CodeProject
Linq-To-XML Node Creation Tutorial at CodeProject
Documentation

Viewing all articles
Browse latest Browse all 37

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>