开发者

How to replace values of XML element

I have this XML document

    <?xml version="1.0" encoding="utf-8" ?>
<session name ="tdsls4401m000">
  <parameters>
    <!-- any of the fields can be specified as parameter : unspecified field values will be take from there default -->
    <parameter name="ornoFrom" target="/session/fields/field[@name='orno.f']" type ="string" >1</parameter>
    <parameter name="ornoTo" target="/session/fields/field[@name='orno.t']" type ="string" >141527</parameter>
    <parameter name="device" target="/session/verbs/setreport/parameter[@name='device']" type="string">123</parameter>
    <!--<parameter name="compFrom" target="/session/fields/field@name[comp.f]" type ="string" >000</parameter>
    <parameter name="compTo" target="/session/fields/field@name[comp.t]" type ="string" >999</parameter>-->

  </parameters>
  <fields>
    <field name="selection" verb="setenum"  debug="true">1</field>
    <field name="orno.f" verb="put"  debug="true"></field>
    <field name="orno.t" verb="put"  debug="true">&开发者_JAVA百科lt;/field>
    <field name="comp.f" verb="put"></field>
    <field name="comp.t" verb="put"></field>
    <field name="prnt.discount" verb="put" value="2"></field>
    <field name="prnt.sellpr" verb="put" value="2"></field>
    <field name="printed" verb="put" value="1"></field>
    <field name="quan.to.print" verb="put" value="1"></field>
    <field name="prnt.options" verb="put" value="2"></field>
    <field name="num.copies" verb="put" value="1"></field>
  </fields>
  <verbs>
    <setreport>
      <parameter name="reportname">"rtdsls440101000"</parameter>
      <parameter name="device">"105"</parameter>
    </setreport>
    <continue/>
  </verbs>
</session>

Now I need to extract each of the /session/parameter@target node (axis) value with the value contained within the parameter element(s).

What would be the best approach to do that ?

Thanks


You can use a xml parsing library: it will allow you to know the value of any node and variables of your xml document. I don't know what libraries there are for c#, but for c++ there is TinyXml. Take a look, perhaps this is a port for .net languages.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜