Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version
Go to top

XMLLib for PUGXML with XPath

, 29 Oct 2009
A library for PugXML which implements XPath
// PugXMLNode.h: interface for the CPugXMLNode class.
// Copyright (C) 2003, by John Crane
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_PUGXMLNODE_H__5CFCBE10_9047_4EA3_A97B_791F66418629__INCLUDED_)
#define AFX_PUGXMLNODE_H__5CFCBE10_9047_4EA3_A97B_791F66418629__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

// Include the Pug XML library.

#define _CRT_SECURE_NO_WARNINGS 1

#include "platform.h"
#include "Array.h"
#include "BString.h"

#include "pugxml.h"
#include <sstream>
#include <io.h>
#include <sys\stat.h>

using namespace std;
using namespace pug;
using namespace blue;
using namespace blue::common;

//
// CPugXMLNode class wraps xml_node and provides
// XPATH functionality.
//
class CPugXMLNode : public xml_node
{
public:
	CPugXMLNode();
	CPugXMLNode(xml_node_struct* p);
    CPugXMLNode(const xml_node& r);
	virtual ~CPugXMLNode();

    // Query functions
    Array <xml_node_struct*> FindNodes(const char* srch);
    xml_node_struct* FindNode(const char* srch);
    Array<BString> FindValues(const char* srch);
    BString FindValue(const char* srch);

    // Copies an existing tree under a node
    void AppendTree(xml_node& node);

    // Shorthand for something we will do all the time
    xml_node_struct* append_child_element(LPCTSTR szName)
    {
        xml_node node =  xml_node::append_child(node_element);
        node.name(szName);
        return (xml_node_struct*) node;
    }
protected:
};

class CAddAttributeNodes : public xml_tree_walker
{
public:
    virtual bool for_each(xml_node& node);
};

class CDelAttributeNodes : public xml_tree_walker
{
public:
    virtual bool for_each(xml_node& node);
};

#endif // !defined(AFX_PUGXMLNODE_H__5CFCBE10_9047_4EA3_A97B_791F66418629__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

JCrane2
Web Developer
United States United States
No Biography provided

| Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 29 Oct 2009
Article Copyright 2003 by JCrane2
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid