Merge "Update deprecated libprivilege-control API functions." into tizen
[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  * @if OSPDEPREC
19  * @file                        FXml.h
20  * @brief                       This is the header file for the Tizen::Xml namespace.
21  *
22  * This header file contains the introduction of the Tizen::Xml namespace.
23  * @endif
24  */
25 #ifndef _FXML_H_
26 #define _FXML_H_
27
28 #include <FBase.h>
29 #include <stdarg.h>
30 #include <stdio.h>
31
32 namespace Tizen
33 {
34 /**
35  * @if OSPDEPREC
36  * @namespace   Tizen::Xml
37  * @brief               <i> [Deprecated] </i> This namespace contains interfaces to manipulate %XML documents.
38  *
39  * @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.
40  *
41  * @since               2.0
42  *
43  * @remarks     Include Libxml2 open source library header and use APIs directly without any additional setting.
44  *
45  *
46  *
47  *
48  *
49  * For more information about using Libxml2 open source library, visit <a href="http://www.xmlsoft.org" target="_blank">http://www.xmlsoft.org</a>
50  *
51  *
52  *      @code
53 // Sample data - map.xml
54 <?xml version="1.0" encoding="ISO-8859-1" ?>
55
56 <map>
57         <item>
58                 <country>United Arab Emirates</country>
59                 <capital>Abu Dhabi</capital>
60         </item>
61         
62         <item>
63                 <country>Nigeria</country>
64                 <capital>Abuja</capital>
65         </item>
66
67         <item>
68                 <country>Ghana</country>
69                 <capital>Accra</capital>
70         </item>
71         
72         <item>
73                 <country>Pitcairn Islands</country>
74                 <capital>Adamstown</capital>
75         </item>                 
76 </map>
77
78 // Sample code for XmlSample.h
79 #include <FBase.h>
80 #include <FUi.h>
81
82 class XmlSample :
83         public Tizen::Ui::Controls::Form
84 {
85 // Construction
86 public:
87         XmlSample(void);
88         ~XmlSample(void);
89
90 public:
91         virtual result OnInitializing(void);
92 };
93
94 // Sample code for XmlSample.cpp
95 #include <libxml/parser.h>
96 #include "XmlSample.h"
97
98 using namespace Tizen::Base;
99
100 result
101 XmlSample::OnInitializing(void)
102 {
103         xmlDocPtr pDocument = null;
104         xmlNodePtr pRoot = null;
105         xmlNodePtr pCurrentElement = null;
106
107         // Creates a XML document
108         pDocument = xmlParseFile("/Home/map.xml");
109         pRoot = xmlDocGetRootElement(pDocument);
110
111         for(pCurrentElement = pRoot->children; pCurrentElement; pCurrentElement = pCurrentElement->next)
112         {
113                 String countryName;
114                 xmlNodePtr pChildElement = null;
115
116                 if(pCurrentElement->type == XML_ELEMENT_NODE)
117                 {
118                         // Gets the <country> element from the <item> element
119                         pChildElement = pCurrentElement->children->next;
120
121                         if(pChildElement)
122                         {
123                                 // Gets the content from XML_TEXT_NODE
124                                 Tizen::Base::Utility::StringUtil::Utf8ToString ((char*)pChildElement->children->content, countryName);
125                                 AppLog("country : %S\n", countryName.GetPointer());
126                         }
127                 }
128         }
129
130         xmlFreeDoc(pDocument);
131         return E_SUCCESS;
132 }
133  *      @endcode
134  * @endif
135  */
136
137 namespace Xml
138 {
139 #include <libxml/parser.h>
140 #include <libxml/HTMLparser.h>
141 #include <libxml/parserInternals.h>
142 #include <libxml/SAX.h>
143 #include <libxml/SAX2.h>
144 #include <libxml/xpath.h>
145 #include <libxml/xmlmemory.h>
146
147 #include <libxml/xmlerror.h>
148 #include <libxml/tree.h>
149
150 #include <libxml/uri.h>
151 #include <libxml/xmlsave.h>
152 #include <libxml/xmlunicode.h>
153 #include <libxml/encoding.h>
154 #include <libxml/xmlIO.h>
155 #include <libxml/xmlwriter.h>
156 #include <libxml/xmlreader.h>
157 #include <libxml/xpathInternals.h>
158
159
160 }; // Tizen::Xml
161 }; // Tizen
162
163 using namespace Tizen::Xml;
164
165 #endif // _FXML_H_