Fix the boiler plate codes
[platform/framework/native/appfw.git] / inc / FXml.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                        FXml.h
19  * @brief                       This is the header file for the Tizen::Xml namespace.
20  *
21  * This header file contains the introduction of the Tizen::Xml namespace.
22  */
23 #ifndef _FXML_H_
24 #define _FXML_H_
25
26 #include <FBase.h>
27 #include <stdarg.h>
28 #include <stdio.h>
29
30 namespace Tizen
31 {
32 /**
33  * @if OSPDEPREC
34  * @namespace   Tizen::Xml
35  * @brief               <i> [Deprecated] </i> This namespace contains interfaces to manipulate %XML documents.
36  *
37  * @deprecated  This namespace is deprecated because Libxml2 open source library is supported by Tizen directly. Instead of using this namespace, use Libxml2 open source library directly.
38  *
39  * @since               2.0
40  *
41  * @remarks     Include Libxml2 open source library header and use APIs directly without any additional setting.
42  *
43  *
44  *
45  *
46  *
47  * For more information about using Libxml2 open source library, visit <a href="http://www.xmlsoft.org" target="_blank">http://www.xmlsoft.org</a>
48  *
49  *
50  *      @code
51 // Sample data - map.xml
52 <?xml version="1.0" encoding="ISO-8859-1" ?>
53
54 <map>
55         <item>
56                 <country>United Arab Emirates</country>
57                 <capital>Abu Dhabi</capital>
58         </item>
59         
60         <item>
61                 <country>Nigeria</country>
62                 <capital>Abuja</capital>
63         </item>
64
65         <item>
66                 <country>Ghana</country>
67                 <capital>Accra</capital>
68         </item>
69         
70         <item>
71                 <country>Pitcairn Islands</country>
72                 <capital>Adamstown</capital>
73         </item>                 
74 </map>
75
76 // Sample code for XmlSample.h
77 #include <FBase.h>
78 #include <FUi.h>
79
80 class XmlSample :
81         public Tizen::Ui::Controls::Form
82 {
83 // Construction
84 public:
85         XmlSample(void);
86         ~XmlSample(void);
87
88 public:
89         virtual result OnInitializing(void);
90 };
91
92 // Sample code for XmlSample.cpp
93 #include <libxml/parser.h>
94 #include "XmlSample.h"
95
96 using namespace Tizen::Base;
97
98 result
99 XmlSample::OnInitializing(void)
100 {
101         xmlDocPtr pDocument = null;
102         xmlNodePtr pRoot = null;
103         xmlNodePtr pCurrentElement = null;
104
105         // Creates a XML document
106         pDocument = xmlParseFile("/Home/map.xml");
107         pRoot = xmlDocGetRootElement(pDocument);
108
109         for(pCurrentElement = pRoot->children; pCurrentElement; pCurrentElement = pCurrentElement->next)
110         {
111                 String countryName;
112                 xmlNodePtr pChildElement = null;
113
114                 if(pCurrentElement->type == XML_ELEMENT_NODE)
115                 {
116                         // Gets the <country> element from the <item> element
117                         pChildElement = pCurrentElement->children->next;
118
119                         if(pChildElement)
120                         {
121                                 // Gets the content from XML_TEXT_NODE
122                                 Tizen::Base::Utility::StringUtil::Utf8ToString ((char*)pChildElement->children->content, countryName);
123                                 AppLog("country : %S\n", countryName.GetPointer());
124                         }
125                 }
126         }
127
128         xmlFreeDoc(pDocument);
129         return E_SUCCESS;
130 }
131  *      @endcode
132  * @endif
133  */
134
135 namespace Xml
136 {
137 #include <libxml/parser.h>
138 #include <libxml/HTMLparser.h>
139 #include <libxml/parserInternals.h>
140 #include <libxml/SAX.h>
141 #include <libxml/SAX2.h>
142 #include <libxml/xpath.h>
143 #include <libxml/xmlmemory.h>
144
145 #include <libxml/xmlerror.h>
146 #include <libxml/tree.h>
147
148 #include <libxml/uri.h>
149 #include <libxml/xmlsave.h>
150 #include <libxml/xmlunicode.h>
151 #include <libxml/encoding.h>
152 #include <libxml/xmlIO.h>
153 #include <libxml/xmlwriter.h>
154 #include <libxml/xmlreader.h>
155 #include <libxml/xpathInternals.h>
156
157
158 }; // Tizen::Xml
159 }; // Tizen
160
161 using namespace Tizen::Xml;
162
163 #endif // _FXML_H_