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