还是昨天的XML文档:
<?xml version="1.0" encoding="GB2312"?>
<ASDF>
<Attribute ServerIP="" IsStart="false"/> <DN>
<Res Desc="Tools1">
<DNList>
<ComplexDN StartDN="0001" EndDN="0001"/>
</DNList>
<RunTime>
<RunPeriod Begin="0" End="1">
<Application Name="ASD" XMLFile="a.exe" Isbound="true" IsAutoStart="false"/>
</RunPeriod>
</RunTime>
</Res>
</DN>
</ASDF>昨天的朋友帮忙解决了如何获得复杂XML值得问题。用:
mChildNode.AttributeNodes['ServerIP'].NodeValue可以获得该值,但是问题又来了,如果ServerIP的值是空的,如上代码中。我用该语句获得该值会返回一个错误,"Could not convert variant of type (Null) into type (String)"请教该如何解决??
<?xml version="1.0" encoding="GB2312"?>
<ASDF>
<Attribute ServerIP="" IsStart="false"/> <DN>
<Res Desc="Tools1">
<DNList>
<ComplexDN StartDN="0001" EndDN="0001"/>
</DNList>
<RunTime>
<RunPeriod Begin="0" End="1">
<Application Name="ASD" XMLFile="a.exe" Isbound="true" IsAutoStart="false"/>
</RunPeriod>
</RunTime>
</Res>
</DN>
</ASDF>昨天的朋友帮忙解决了如何获得复杂XML值得问题。用:
mChildNode.AttributeNodes['ServerIP'].NodeValue可以获得该值,但是问题又来了,如果ServerIP的值是空的,如上代码中。我用该语句获得该值会返回一个错误,"Could not convert variant of type (Null) into type (String)"请教该如何解决??
mStr:=mChildNode.AttributeNodes['StartDN'].Text;
但必须在uses 中包含Variants
小弟来补充一下
if Nodename.AttributeNodes['StartDN']<>nil then 这个是判断节点属性得值不为空
if nodename.Nodevalue<>nil 这个是判断节点得值不为空