如何获取xmlHashTable的钥匙? (libxml2的) [英] how to get the keys of a xmlHashTable ? (libxml2)
问题描述
我使用的libxml2库解析XML文档。然后,我在这个图书馆看到 xmlHashTable
。是否有可能得到的所有键 xmlHashTable
?我想存储阵列中的所有关键点。
I am using the library libxml2 to parse an XML document. And then I saw xmlHashTable
in this library. Is it possible to get all the keys of a xmlHashTable
? I want to store all the keys in an array.
XML文档:
<?xml version="1.0" encoding="UTF-8"?>
<?type-proto key="MIPRegistrationRequest" value="mip" ?>
<?avp-proto key="Example-AVP" value="data" ?>
<!DOCTYPE dictionary SYSTEM "dictionary.dtd" [
<!-- Any files added here need to be added to Makefile.am and
packaging/nsis/wireshark.nsi -->
<!ENTITY nasreq SYSTEM "nasreq.xml">
<!ENTITY eap SYSTEM "eap.xml">
<!ENTITY mobileipv4 SYSTEM "mobileipv4.xml">
<!ENTITY chargecontrol SYSTEM "chargecontrol.xml">
<!ENTITY sunping SYSTEM "sunping.xml">
<!ENTITY TGPP SYSTEM "TGPP.xml">
<!ENTITY TGPP2 SYSTEM "TGPP2.xml">
<!ENTITY sip SYSTEM "sip.xml">
<!ENTITY etsie2e4 SYSTEM "etsie2e4.xml">
<!ENTITY Ericsson SYSTEM "Ericsson.xml">
<!ENTITY mobileipv6 SYSTEM "mobileipv6.xml">
<!ENTITY Cisco SYSTEM "Cisco.xml">
<!ENTITY Starent SYSTEM "Starent.xml">
<!ENTITY Vodafone SYSTEM "Vodafone.xml">
<!ENTITY AlcatelLucent SYSTEM "AlcatelLucent.xml">
<!ENTITY Nokia SYSTEM "Nokia.xml">
<!ENTITY NokiaSolutionsAndNetworks SYSTEM "NokiaSolutionsAndNetworks.xml">
<!ENTITY HP SYSTEM "HP.xml">
<!ENTITY Oracle SYSTEM "Oracle.xml">
<!ENTITY Custom SYSTEM "Custom.xml">
]>
<dictionary>
...
<dictionary>
结果
我试图让外部(解析)实体的所有键(如NASREQ,EAP等):
结果
I am trying to get the all the keys of the external (parsed) entities (such as nasreq, eap etc):
ddict_t *ddict_scan(const char* system_directory, const char* filename)
{
char *path = g_strconcat((const gchar*) system_directory, (const gchar*)filename, (const gchar *)'\0');
xmlDocPtr p1 = getdoc((const char *)path);
xmlEntitiesTablePtr ptr2 = p1->intSubset->entities;
//to be added
}
类型 xmlEntitiesTable
的是 xmlHashTable
。
推荐答案
有是 xmlHashScan ()函数(及其挑剔亲属),它可用于具有用户提供的 xmlHashScanner 函数调用回由库在 xmlHashTable
每个条目。在 xmlHashScanner
给出名称
每个条目作为参数,所以它应该是易于组装的所有列表键的方式。
There is the xmlHashScan() function (and its pickier relatives), which can be used to have a user-provided xmlHashScanner function called back by the library for each entry in the xmlHashTable
. The xmlHashScanner
is given the name
of each entry as parameter, so it should be easy to assemble a list of all the keys that way.
这篇关于如何获取xmlHashTable的钥匙? (libxml2的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!