VB6修改XML文件指定位置的文本的代码? 5
<?xmlversion="1.0"?><featuresxmlns="x-schema:pmillmt.xml"><featuresetunit="metric"><w...
<?xml version="1.0"?>
<features xmlns="x-schema:pmillmt.xml">
<featureset unit="metric">
<workplane>
<point X="0" Y="0" Z="0"/>
<u_vector I="1" J="0" K="0"/>
<v_vector I="0" J="1" K="0"/>
<w_vector I="0" J="0" K="1"/>
</workplane>
<compound_hole component="1" hole_definition="hole1" name="1">
<point X="-1.667" Y="83.75" Z="0"/>
<axis I="-0" J="-0" K="-1"/>
</compound_hole>
<compound_hole component="1" hole_definition="hole2" name="2">
<point X="-46.246" Y="-38.172" Z="0"/>
<axis I="-0" J="-0" K="-1"/>
</compound_hole>
<compound_hole component="1" hole_definition="hole1" name="3">
<point X="-144.88" Y="-36.083" Z="0"/>
<axis I="-0" J="-0" K="-1"/>
</compound_hole>
<compound_hole component="1" hole_definition="hole1" name="4">
<point X="140" Y="-36.083" Z="0"/>
<axis I="-0" J="-0" K="-1"/>
</compound_hole>
<compound_hole component="1" hole_definition="hole2" name="5">
<point X="-46.246" Y="7.162" Z="0"/>
<axis I="-0" J="-0" K="-1"/>
</compound_hole>
<compound_hole component="1" hole_definition="hole3" name="6">
<point X="-92.222" Y="-38.172" Z="0"/>
<axis I="-0" J="-0" K="-1"/>
</compound_hole>
<compound_hole component="1" hole_definition="hole1" name="7">
<point X="-144.88" Y="-65.454" Z="0"/>
<axis I="-0" J="-0" K="-1"/>
</compound_hole>
<compound_hole component="1" hole_definition="hole1" name="8">
<point X="140" Y="-70" Z="0"/>
<axis I="-0" J="-0" K="-1"/>
</compound_hole>
</featureset>
<hole_defs>
<hole_def id="hole1" description="description" hole_type="type">
<hole>
<geometry diameter="20" taper="0" depth="40"/>
</hole>
</hole_def>
<hole_def id="hole2" description="description" hole_type="type">
<hole>
<geometry diameter="21.573" taper="0" depth="20"/>
</hole>
</hole_def>
<hole_def id="hole3" description="description" hole_type="type">
<hole>
<geometry diameter="20" taper="0" depth="20"/>
</hole>
</hole_def>
</hole_defs>
</features>
想修改<geometry diameter="21.573" taper="0" depth="20"/>这里的深度20修改为我计算的数值?VB6代码怎么写?
这是我的源代码,但是怎么替换20我不会了,请求帮助!谢谢! 展开
<features xmlns="x-schema:pmillmt.xml">
<featureset unit="metric">
<workplane>
<point X="0" Y="0" Z="0"/>
<u_vector I="1" J="0" K="0"/>
<v_vector I="0" J="1" K="0"/>
<w_vector I="0" J="0" K="1"/>
</workplane>
<compound_hole component="1" hole_definition="hole1" name="1">
<point X="-1.667" Y="83.75" Z="0"/>
<axis I="-0" J="-0" K="-1"/>
</compound_hole>
<compound_hole component="1" hole_definition="hole2" name="2">
<point X="-46.246" Y="-38.172" Z="0"/>
<axis I="-0" J="-0" K="-1"/>
</compound_hole>
<compound_hole component="1" hole_definition="hole1" name="3">
<point X="-144.88" Y="-36.083" Z="0"/>
<axis I="-0" J="-0" K="-1"/>
</compound_hole>
<compound_hole component="1" hole_definition="hole1" name="4">
<point X="140" Y="-36.083" Z="0"/>
<axis I="-0" J="-0" K="-1"/>
</compound_hole>
<compound_hole component="1" hole_definition="hole2" name="5">
<point X="-46.246" Y="7.162" Z="0"/>
<axis I="-0" J="-0" K="-1"/>
</compound_hole>
<compound_hole component="1" hole_definition="hole3" name="6">
<point X="-92.222" Y="-38.172" Z="0"/>
<axis I="-0" J="-0" K="-1"/>
</compound_hole>
<compound_hole component="1" hole_definition="hole1" name="7">
<point X="-144.88" Y="-65.454" Z="0"/>
<axis I="-0" J="-0" K="-1"/>
</compound_hole>
<compound_hole component="1" hole_definition="hole1" name="8">
<point X="140" Y="-70" Z="0"/>
<axis I="-0" J="-0" K="-1"/>
</compound_hole>
</featureset>
<hole_defs>
<hole_def id="hole1" description="description" hole_type="type">
<hole>
<geometry diameter="20" taper="0" depth="40"/>
</hole>
</hole_def>
<hole_def id="hole2" description="description" hole_type="type">
<hole>
<geometry diameter="21.573" taper="0" depth="20"/>
</hole>
</hole_def>
<hole_def id="hole3" description="description" hole_type="type">
<hole>
<geometry diameter="20" taper="0" depth="20"/>
</hole>
</hole_def>
</hole_defs>
</features>
想修改<geometry diameter="21.573" taper="0" depth="20"/>这里的深度20修改为我计算的数值?VB6代码怎么写?
这是我的源代码,但是怎么替换20我不会了,请求帮助!谢谢! 展开
1个回答
展开全部
'xml文本中有 :xmlns="x-schema:pmillmt.xml" 串时对象没法读取
Private Sub Command1_Click()
Dim xmldoc As New MSXML2.DOMDocument
xmldoc.async = False
If xmldoc.Load(App.Path & "\test.xml") Then
Dim list As IXMLDOMNodeList
Set list = xmldoc.selectNodes("//features/hole_defs/hole_def/hole/geometry")
Dim node As IXMLDOMNode
Dim anode As IXMLDOMNode
For Each node In list
Set anode = node.Attributes.getNamedItem("depth") '获取属性结点
anode.nodeValue = Val(anode.nodeValue) * 3 '对属性值赋值即可
Next
End If
xmldoc.save App.Path & "\test.xml"
End Sub
来自:求助得到的回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询