Click here to Skip to main content
15,885,007 members
Articles / Programming Languages / Visual Basic

EfTidy: The Tidy Library Wrapper

Rate me:
Please Sign up or sign in to vote.
4.91/5 (36 votes)
6 Sep 2013GPL310 min read 185K   5K   88  
A free component for HTML parsing and cleaning
// EfTidyNode.cpp : Implementation of CEfTidyNode
#include "stdafx.h"
#include "EfTidy.h"
#include "EfTidyNode.h"
#include "EfTidyAttr.h"

/////////////////////////////////////////////////////////////////////////////
// CEfTidyNode

/*********************************************************************
  Property Name:get_Messages(short *pVal)
  Last Modified:17 oct 2005
  Function Descrption: return total message count
  Interafce Support =YES
 *********************************************************************/

STDMETHODIMP CEfTidyNode::get_Name(BSTR *pVal)
{
	//USES_CONVERSION;
	ctmbstr NodeName=tidyNodeGetName(this->m_pNode);
	*pVal=CComBSTR(NodeName).Detach();


	return S_OK;
}

/*********************************************************************
  Property Name:get_Messages(short *pVal)
  Last Modified:19 oct 2004
  Function Descrption: return total message count
  Interafce Support =YES
 *********************************************************************/

STDMETHODIMP CEfTidyNode::GetFirstChildNode(IEfTidyNode **ppNewNode)
{
	
	TidyNode LocalNode;
	LocalNode=tidyGetChild(this->m_pNode);
	//ctmbstr NodeName=tidyNodeGetName(LocalNode);


	
	if(LocalNode==NULL)
	{
		*ppNewNode=NULL;
		return S_FALSE;
	}

	

	CComObject<CEfTidyNode>* m_pTidyNode;
	HRESULT hr =  CComObject<CEfTidyNode>::CreateInstance(&m_pTidyNode);

	//give value to new Interface
	m_pTidyNode->setTidyDocument(this->m_ptidyDocument);

	m_pTidyNode->m_pNode=LocalNode;

	//store it for next iteration
	this->m_tmpNode=LocalNode;



	hr =m_pTidyNode->QueryInterface(__uuidof(IEfTidyNode),
		reinterpret_cast<void**>(ppNewNode));

	return S_OK;
}
/*********************************************************************
  Property Name:get_Messages(short *pVal)
  Last Modified:19 oct 2004
  Function Descrption: return total message count
  Interafce Support =YES
 *********************************************************************/

STDMETHODIMP CEfTidyNode::GetNextChildNode(IEfTidyNode **ppNewNode)
{

	TidyNode LocalNode;
	LocalNode=tidyGetNext(this->m_tmpNode);
	ctmbstr NodeName=tidyNodeGetName(LocalNode);
	
	
	if(LocalNode==NULL)
	{
		*ppNewNode=NULL;
		return S_FALSE;
	}



	CComObject<CEfTidyNode>* m_pTidyNode;
	HRESULT hr =  CComObject<CEfTidyNode>::CreateInstance(&m_pTidyNode);

	//give values
	m_pTidyNode->setTidyDocument(this->m_ptidyDocument);
	m_pTidyNode->m_pNode=LocalNode;
	//store it for next iteration
	this->m_tmpNode=LocalNode;

	hr =m_pTidyNode->QueryInterface(__uuidof(IEfTidyNode),
		reinterpret_cast<void**>(ppNewNode));

	return S_OK;
}

/*********************************************************************
  Property Name:get_Messages(short *pVal)
  Last Modified:19 oct 2004
  Function Descrption: return total message count
  Interafce Support =YES
 *********************************************************************/


STDMETHODIMP CEfTidyNode::GetFirstAttribute(IEfTidyAttr **ppNewAttr)
{
    TidyAttr LocalAttr;
	*ppNewAttr=NULL;
	LocalAttr=tidyAttrFirst(this->m_pNode);
	
	//ctmbstr NodeName=tidyNodeGetName(LocalNode);
	
	if(LocalAttr==NULL)
	{
		*ppNewAttr=NULL;
		return S_FALSE;
	}

	

	CComObject<CEfTidyAttr>* m_pTidyAttr;
	HRESULT hr =  CComObject<CEfTidyAttr>::CreateInstance(&m_pTidyAttr);

	//give value to new Interface
	
	m_pTidyAttr->m_TidyAttr=LocalAttr;

	//store it for next iteration
	this->m_tmpattr=LocalAttr;



	hr =m_pTidyAttr->QueryInterface(__uuidof(IEfTidyAttr),
		reinterpret_cast<void**>(ppNewAttr));
}

STDMETHODIMP CEfTidyNode::GetNextAttribute(IEfTidyAttr **ppNewAttr)
{
	TidyAttr LocalAttr;
	*ppNewAttr=NULL;

	if(this->m_tmpattr)
	{
		LocalAttr=tidyAttrNext(this->m_tmpattr);
		
		//ctmbstr NodeName=tidyNodeGetName(LocalNode);
		
		if(LocalAttr==NULL)
		{
		   return S_FALSE;
		}
		
		CComObject<CEfTidyAttr>* m_pTidyAttr;
		HRESULT hr =  CComObject<CEfTidyAttr>::CreateInstance(&m_pTidyAttr);

		//give value to new Interface
		
		m_pTidyAttr->m_TidyAttr=LocalAttr;

		//store it for next iteration
		this->m_tmpattr=LocalAttr;

        hr =m_pTidyAttr->QueryInterface(__uuidof(IEfTidyAttr),
			reinterpret_cast<void**>(ppNewAttr));
	}
 return S_OK;
}

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 GNU General Public License (GPLv3)


Written By
Software Developer (Senior)
India India
He used to have biography here Smile | :) , but now he will hire someone (for free offcourse Big Grin | :-D ), Who writes his biography on his behalf Smile | :)

He is Great Fan of Mr. Johan Rosengren (his idol),Lim Bio Liong, Nishant S and DavidCrow and Believes that, he will EXCEL in his life by following there steps!!!

He started with Visual C++ then moved to C# then he become language agnostic, you give him task,tell him the language or platform, he we start immediately, if he knows the language otherwise he quickly learn it and start contributing productively

Last but not the least, For good 8 years he was Visual CPP MSMVP!

Comments and Discussions