Exemple #1
0
void MyHandler::startElement(const Poco::XML::XMLString& namespaceURI, const Poco::XML::XMLString& localName, const Poco::XML::XMLString& qname, const Poco::XML::Attributes& attributes) {
    // We have reached the actual weather data in the xml string.
    if (qname == "measurementSiteTable") {
        location_data = true;
    }
    // Set counter to zero. When counter reaches three the current qname value is used as key.
    if (qname == "measurementSiteName" && location_data) {
        counter = 0;
    }
    if (location_data) {
        ++counter;
    }

    // Get id of site.
    if (qname == "measurementSiteRecord") {
        if (attributes.getLength()) {
            x = attributes.getLength();
            for (int i = 0; i < x; ++i) {
                if (attributes.getQName(i) == "id") {
                    _site_id = attributes.getValue(i);
//                    std::cout << "site id: " << _site_id << std::endl;
                }
            }
        }
    }

    // Get latitude and longitude.
    if (qname == "latitude") {
        _lat = true;
    }
    if (qname == "longitude") {
        _lon = true;
    }
}
Exemple #2
0
	void startElement(const Poco::XML::XMLString& uri, const Poco::XML::XMLString& localName, const Poco::XML::XMLString& qname, const Poco::XML::Attributes& attributes)
	{
		where("startElement");
		m_Msg.Message(Poco::format("    uri:       %s", uri));
		m_Msg.Message(Poco::format("    localName: %s", localName));
		m_Msg.Message(Poco::format("    qname:     %s", qname));
		if(0 != attributes.getLength())
		{
			m_Msg.Message("    Attributes: ");
			for(int i=0; i<attributes.getLength(); ++i)
			{
				m_Msg.Message(Poco::format("     %s=\"%s\"", attributes.getLocalName(i), attributes.getValue(i)));
			}
		}
	}
Exemple #3
0
 void AbstractXULParser::getAttributes(const Poco::XML::Attributes & inXMLAttributes,
                                       AttributesMapping & outXULAttributes)
 {
     for (int idx = 0; idx != inXMLAttributes.getLength(); ++idx)
     {
         const Poco::XML::XMLString & name = inXMLAttributes.getLocalName(idx);
         const Poco::XML::XMLString & value = inXMLAttributes.getValue(idx);
         outXULAttributes[name] = value;
     }
 }
Exemple #4
0
void VSXMLWriter::startElement(const Poco::XML::XMLString& namespaceURI, const Poco::XML::XMLString& localName, const Poco::XML::XMLString& qname, const Poco::XML::Attributes& attributes)
{
	if (!_tagClosed.back())
	{
		_ostr << ">\r\n";
		_tagClosed.back() = true;
	}
	indent();
	++_indent;
	_ostr << "<" << qname;
	if (attributes.getLength() > 0)
	{
		Poco::XML::AttributesImpl sortedAttributes;
		if (qname == "VisualStudioProject")
		{
			sortedAttributes.addAttribute("", "", "Name", "CDATA", attributes.getValue("Name"));
			sortedAttributes.addAttribute("", "", "Version", "CDATA", attributes.getValue("Version"));
			sortedAttributes.addAttribute("", "", "ProjectType", "CDATA", attributes.getValue("ProjectType"));
			sortedAttributes.addAttribute("", "", "ProjectGUID", "CDATA", attributes.getValue("ProjectGUID"));
			sortedAttributes.addAttribute("", "", "RootNamespace", "CDATA", attributes.getValue("RootNamespace"));
			sortedAttributes.addAttribute("", "", "Keyword", "CDATA", attributes.getValue("Keyword"));
		}
		else
		{
			if (attributes.getIndex("Name") != -1)
			{
				sortedAttributes.addAttribute("", "", "Name", "CDATA", attributes.getValue("Name"));
			}
			for (int i = 0; i < attributes.getLength(); i++)
			{
				if (attributes.getQName(i) != "Name")
				{
					std::string value = attributes.getValue(i);
					if (_convertBool && (value == "true" || value == "false"))	
						value = Poco::toUpper(value);
					sortedAttributes.addAttribute(attributes.getURI(i), attributes.getLocalName(i), attributes.getQName(i), attributes.getType(i), value);
				}
			}
		}
		for (int i = 0; i < sortedAttributes.getLength(); i++)
		{
			_ostr << "\r\n";
			indent();
			_ostr << sortedAttributes.getQName(i) << "=\"";
			std::string value = sortedAttributes.getValue(i);
			for (Poco::XML::XMLString::const_iterator itv = value.begin(); itv != value.end(); ++itv)
			{
				char c = *itv;
				switch (c)
				{
				case '"':  _ostr << "&quot;"; break;
				case '\'': _ostr << "&apos;"; break;
				case '&':  _ostr << "&amp;"; break;
				case '<':  _ostr << "&lt;"; break;
				case '>':  _ostr << "&gt;"; break;
				case '\t': _ostr << "&#x9;"; break;
				case '\r': _ostr << "&#xD;"; break;
				case '\n': _ostr << "&#xA;"; break;
				default:   _ostr << c; break;
				}
			}
			_ostr << "\"";
		}
	}
	_tagClosed.push_back(false);
}