2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "DAVCommon.h"
22 #include "utils/StringUtils.h"
23 #include "utils/log.h"
25 using namespace XFILE;
28 * Return true if pElement value is equal value without namespace.
30 * if pElement is <DAV:foo> and value is foo then ValueWithoutNamespace is true
32 bool CDAVCommon::ValueWithoutNamespace(const TiXmlNode *pNode, const std::string& value)
35 const TiXmlElement *pElement;
42 pElement = pNode->ToElement();
49 StringUtils::SplitString(pElement->Value(), ":", tag, 2);
51 if (tag.size() == 1 && tag[0] == value)
55 else if (tag.size() == 2 && tag[1] == value)
59 else if (tag.size() > 2)
61 CLog::Log(LOGERROR, "%s - Splitting %s failed, size(): %lu, value: %s", __FUNCTION__, pElement->Value(), (unsigned long int)tag.size(), value.c_str());
68 * Search for <status> and return its content
70 std::string CDAVCommon::GetStatusTag(const TiXmlElement *pElement)
72 const TiXmlElement *pChild;
74 for (pChild = pElement->FirstChild()->ToElement(); pChild != 0; pChild = pChild->NextSibling()->ToElement())
76 if (ValueWithoutNamespace(pChild, "status"))
78 return pChild->GetText();