user-0 提问: 求助用c语言  解析字符 应该怎么样去解析

回复:
user: user-1
content: 引用 2 楼 m0_37820090 的回复:恩  但是有些原因不能用 xml 解析的方法去解析，需要解析直接得到 按照字符串解析函数一行行的分析，会比较麻烦；

user: user-0
content: 恩  但是有些原因不能用 xml 解析的方法去解析，需要解析直接得到

user: user-2
content: 用msxml组件

user: user-3
content: __min Returns the smaller of two values.  type __min( type a, type b );  Routine Required Header Compatibility  __min <stdlib.h> Win 95, Win NT    For additional compatibility information, see Compatibility in the Introduction.  Libraries  LIBC.LIB Single thread static library, retail version  LIBCMT.LIB Multithread static library, retail version  MSVCRT.LIB Import library for MSVCRT.DLL, retail version    Return Value  The smaller of the two arguments  Parameters  type  Any numeric data type  a, b  Values of any numeric type to be compared  Remarks  The __min macro compares two values and returns the value of the smaller one. The arguments can be of any numeric data type, signed or unsigned. Both arguments and the return value must be of the same data type.  Example  /* MINMAX.C */  #include <stdlib.h> #include <stdio.h>  void main( void ) {    int a = 10;    int b = 21;     printf( "The larger of %d and %d is %d\n",  a, b, __max( a, b ) );    printf( "The smaller of %d and %d is %d\n", a, b, __min( a, b ) ); }   Output  The larger of 10 and 21 is 21 The smaller of 10 and 21 is 10   Floating-Point Support Routines  See Also   __max   File: "C:\Program Files\Microsoft Visual Studio 10.0\VC\include\stdlib.h"      175: #define __min(a,b)  (((a) < (b)) ? (a) : (b))

user: user-0
content: 结帖了 谢谢各位

user: user-0
content: 引用 4 楼 zhao4zhong1 的回复:#include <stdio.h> #include <string.h> #include <stdlib.h> char htmls[]= "htmlID=1001&MessageID=196&<rpc message-id=\"196\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" "<get><filter type=\"subtree\"><featurename istop=\"true\" type=\"mib\"><entPhysicalEntry position=\"iso.org.dod.internet.mgmt.mib-2.entityMIB.entityMIBObjects.entityPhysical.entPhysicalTable\"><entPhysicalSerialNum/><entPhysicalDescr/></entPhysicalEntry></featurename></filter></get></rpc>]]>]]>" "htmlID=1001&MessageID=196&<rpc message-id=\"196\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" "<get><filter type=\"subtree\">" "<featurename istop=\"true\" type=\"mib\">" "    <EntityStateEntry position=\"iso.org.dod.internet.private.enterprises.Mgmt.Datacomm.EntityExtentMIB.EntityExtObjects.EntityState.EntityStateTable\">" "        <EntityCpuUsage/>" "        <EntityMemUsage/>" "        <EntityTemperature/>" "        <EntityCpuUsageThreshold/>" "        <EntityMemUsageThreshold/>" "        <EntityTemperatureThreshold/>" "    </EntityStateEntry>" "</featurename>" "</filter>" "</get>" "</rpc>]]>]]>"; char *s,*p,*q,t[80+1]; int L; int main() {     s=(char *)htmls;     while (1) {         p=strstr(s,"<featurename ");         if (!p) break;         s=p;         p=strstr(s,">");         if (!p) break;         s=p;         p=strstr(s,"<");         if (!p) break;         q=strstr(p," ");         if (!q) break;         L=__min(80,q-p-1);         strncpy(t,p+1,L);t[L]=0;         printf("[%s]\n",t);         s=q+1;     }     return 0; } //[entPhysicalEntry] //[EntityStateEntry] //  编译会出现   undefined reference to `_min'

user: user-3
content: #include <stdio.h> #include <string.h> #include <stdlib.h> char htmls[]= "htmlID=1001&MessageID=196&<rpc message-id=\"196\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" "<get><filter type=\"subtree\"><featurename istop=\"true\" type=\"mib\"><entPhysicalEntry position=\"iso.org.dod.internet.mgmt.mib-2.entityMIB.entityMIBObjects.entityPhysical.entPhysicalTable\"><entPhysicalSerialNum/><entPhysicalDescr/></entPhysicalEntry></featurename></filter></get></rpc>]]>]]>" "htmlID=1001&MessageID=196&<rpc message-id=\"196\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" "<get><filter type=\"subtree\">" "<featurename istop=\"true\" type=\"mib\">" "    <EntityStateEntry position=\"iso.org.dod.internet.private.enterprises.Mgmt.Datacomm.EntityExtentMIB.EntityExtObjects.EntityState.EntityStateTable\">" "        <EntityCpuUsage/>" "        <EntityMemUsage/>" "        <EntityTemperature/>" "        <EntityCpuUsageThreshold/>" "        <EntityMemUsageThreshold/>" "        <EntityTemperatureThreshold/>" "    </EntityStateEntry>" "</featurename>" "</filter>" "</get>" "</rpc>]]>]]>"; char *s,*p,*q,t[80+1]; int L; int main() {     s=(char *)htmls;     while (1) {         p=strstr(s,"<featurename ");         if (!p) break;         s=p;         p=strstr(s,">");         if (!p) break;         s=p;         p=strstr(s,"<");         if (!p) break;         q=strstr(p," ");         if (!q) break;         L=__min(80,q-p-1);         strncpy(t,p+1,L);t[L]=0;         printf("[%s]\n",t);         s=q+1;     }     return 0; } //[entPhysicalEntry] //[EntityStateEntry] //