|
a/libupnpp/ixmlwrap.cxx |
|
b/libupnpp/ixmlwrap.cxx |
1 |
/* Copyright (C) 2013 J.F.Dockes
|
1 |
/* Copyright (C) 2013 J.F.Dockes
|
2 |
* This program is free software; you can redistribute it and/or modify
|
2 |
* This program is free software; you can redistribute it and/or modify
|
3 |
* it under the terms of the GNU General Public License as published by
|
3 |
* it under the terms of the GNU General Public License as published by
|
4 |
* the Free Software Foundation; either version 2 of the License, or
|
4 |
* the Free Software Foundation; either version 2 of the License, or
|
5 |
* (at your option) any later version.
|
5 |
* (at your option) any later version.
|
6 |
*
|
6 |
*
|
7 |
* This program is distributed in the hope that it will be useful,
|
7 |
* This program is distributed in the hope that it will be useful,
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10 |
* GNU General Public License for more details.
|
10 |
* GNU General Public License for more details.
|
11 |
*
|
11 |
*
|
12 |
* You should have received a copy of the GNU General Public License
|
12 |
* You should have received a copy of the GNU General Public License
|
13 |
* along with this program; if not, write to the
|
13 |
* along with this program; if not, write to the
|
14 |
* Free Software Foundation, Inc.,
|
14 |
* Free Software Foundation, Inc.,
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16 |
*/
|
16 |
*/
|
17 |
#include "config.h"
|
17 |
#include "config.h"
|
18 |
|
18 |
|
19 |
#include <string>
|
19 |
#include <string>
|
20 |
using std::string;
|
20 |
using std::string;
|
21 |
|
21 |
|
22 |
#include <upnp/ixml.h>
|
22 |
#include <upnp/ixml.h>
|
23 |
|
23 |
|
24 |
#include "ixmlwrap.hxx"
|
24 |
#include "libupnpp/ixmlwrap.hxx"
|
25 |
|
25 |
|
26 |
namespace ixmlwrap {
|
26 |
namespace ixmlwrap {
|
27 |
|
27 |
|
28 |
// Get the value for the first element in the document with the given name.
|
28 |
// Get the value for the first element in the document with the given name.
|
29 |
// There should be only one such element for this to make any sense.
|
29 |
// There should be only one such element for this to make any sense.
|
30 |
string getFirstElementValue(IXML_Document *doc, const string& name)
|
30 |
string getFirstElementValue(IXML_Document *doc, const string& name)
|
31 |
{
|
31 |
{
|
32 |
string ret;
|
32 |
string ret;
|
33 |
IXML_NodeList *nodes =
|
33 |
IXML_NodeList *nodes =
|
34 |
ixmlDocument_getElementsByTagName(doc, name.c_str());
|
34 |
ixmlDocument_getElementsByTagName(doc, name.c_str());
|
35 |
|
35 |
|
36 |
if (nodes) {
|
36 |
if (nodes) {
|
37 |
IXML_Node *first = ixmlNodeList_item(nodes, 0);
|
37 |
IXML_Node *first = ixmlNodeList_item(nodes, 0);
|
38 |
if (first) {
|
38 |
if (first) {
|
39 |
IXML_Node *dnode = ixmlNode_getFirstChild(first);
|
39 |
IXML_Node *dnode = ixmlNode_getFirstChild(first);
|
40 |
if (dnode) {
|
40 |
if (dnode) {
|
41 |
ret = ixmlNode_getNodeValue(dnode);
|
41 |
ret = ixmlNode_getNodeValue(dnode);
|
42 |
}
|
42 |
}
|
43 |
}
|
43 |
}
|
44 |
}
|
44 |
}
|
45 |
|
45 |
|
46 |
if(nodes)
|
46 |
if(nodes)
|
47 |
ixmlNodeList_free(nodes);
|
47 |
ixmlNodeList_free(nodes);
|
48 |
return ret;
|
48 |
return ret;
|
49 |
}
|
49 |
}
|
50 |
|
50 |
|
51 |
}
|
51 |
}
|
52 |
/* Local Variables: */
|
|
|
53 |
/* mode: c++ */
|
|
|
54 |
/* c-basic-offset: 4 */
|
|
|
55 |
/* tab-width: 4 */
|
|
|
56 |
/* indent-tabs-mode: t */
|
|
|
57 |
/* End: */
|
|
|