VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
xmlParseUtil.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2005 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: xmlParseUtil.h,v $ $Revision: 1.2 $ $State: Exp $
7 *******************************************************************************/
8 
9 #ifndef xmlParseUtil_H_
10 #define xmlParseUtil_H_
11 #include <vrvUtil/signalslib.h>
12 
13 //
14 // \file xmlParseUtil.h
15 // \brief Collections of utility functions to aid in parsing XML files.
16 //
17 
18 #include <vlutil/vlString.h>
19 #include <libxml/xmlreader.h>
20 
21 // Finds the first node whose tag matches the one given by \p nodeName.
22 // \param node Starting node for the search inside the xml document
23 // \param nodeName Name of the node to be searched (e.g. "GridStructure")
24 // \return 0 if no matches are found.
25 xmlNodePtr DtXmlFindNode(xmlNodePtr node, const char* nodeName);
26 
27 // Finds the node named as nodeName and that also has an attribute named
28 // attrName with a value of attrValue. For example,
29 // <tt>findNode(nodeptr, "GridStructure", "name", "abc")</tt> searches for a
30 // node that looks like <br> <br> <tt>
31 // <GridStructure name="abc"> <br>
32 // ... <br>
33 // </GridStructure>
34 // </tt>
35 // \return 0 if no matches are found.
36 xmlNodePtr DtXmlFindNode(xmlNodePtr node, const char* nodeName,
37  const char* attrName, const char *attrValue);
38 
39 // Returns the value of the attribute attrname inside the node. Attributes
40 // are specified inside the node like this <br><br> <tt>
41 // <node \e attrname=\e value ...> <br>
42 // ... <br>
43 // </node>
44 // </tt>
45 // \param node Node to access
46 // \param attrname Name of the attribute to be searched (e.g. "name")
47 // \return The attribute's value if present or an empty DtSring otherwise.
48 DtString DtXmlGetAttrValue(xmlNodePtr node, const char* attrname);
49 
50 // Returns the value of an "atomic" node. Atomic nodes are the ones that
51 // have the following structure <tt><tag>value</tag></tt>.
52 // \param node Node to start the search of the atomic node
53 // \param nodeName Name of the atomic node to be searched
54 // \return It returns an empty DtString if the node has the form or <tag></tag>
55 DtString DtXmlGetAtomicNodeValue(xmlNodePtr node, const char* nodeName);
56 
57 // \return the next node which is not a blank text node
58 void DtXmlNextNode(xmlNodePtr& node);
59 
60 // Returns the value of an "atomic" node. Atomic nodes are the ones that
61 // have the following structure <tag>value</tag>. It returns the empty
62 // string if the node has the form or <tag></tag>
63 DtString DtXmlGetAtomicNodeValue(xmlNodePtr node);
64 
65 // Returns a pointer to the first child of the node or NULL if not defined
66 // The reason for this method is because libXml also includes blank text
67 // nodes sometimes, so they need to be filtered out. This function
68 // guarantees you get an actual child node as the first node
69 xmlNodePtr DtXmlGetChildren(xmlNodePtr node);
70 
71 #endif

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)