将新数据附加到现有XML以进行输出? [英] Append new data to existing XML for output?

查看:50
本文介绍了将新数据附加到现有XML以进行输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很确定这是一种非常好吃的方式,我一直坚持不懈地努力,并且很快就会在几件事情上匆匆忙忙地等待,并且可能正处于过度思考的地步

这...


我通过网络服务中的字符串Feed收到传入的XML文档:


< Root>

<产品>

<文件>订单< /文件>

< Origin> OregonOffice< / Origin> ;

< Details Name =" Product"值= QUOT;粘合剂" />

< Details Name =" Qty"值= QUOT 1 QUOT; />

< / Product>

< / root>


我需要修改传出的XML来读取批准检查的状态:


< Root>

<产品>

<文件>订单< /文件>

< Origin> OregonOffice< / Origin>

< Details Name =" Product"值= QUOT;粘合剂" />

< Details Name =" Qty"值= QUOT 1 QUOT; />

< Details Name =" Approved"值= QUOT假QUOT; />

< / Product>

< / Root>


一旦我得到真或假的值一个方法调用,我如何修改

XML来添加新属性?


TIA

-Rich

I''m sure there''s a very weasy way to do this, I''ve been running hard and
fast on several things at once and just may be at the point of overthinking
this...

I receive an incoming XML document via a string feed within a web service:

<Root>
<Product>
<File>Order</File>
<Origin>OregonOffice</Origin>
<Details Name="Product" Value="Binder" />
<Details Name="Qty" Value="1" />
</Product>
</Root>

I need to modify the outgoing XML to read the status of an approval check:

<Root>
<Product>
<File>Order</File>
<Origin>OregonOffice</Origin>
<Details Name="Product" Value="Binder" />
<Details Name="Qty" Value="1" />
<Details Name="Approved" Value="False" />
</Product>
</Root>

Once I have the True or False value from a method call, how would I modify
the XML to add the new attributes?

TIA
-Rich

推荐答案

dim dom as new XmlDocumen

dom.loadxml(yourxmlstring

dim products as XmlNodeList = dom .selectnodes(descendant :: product


对于每个产品作为产品中的XmlNode

dim bApproved as Boolean = GetApprovalValue()''得到你的布尔值为每个产品标记

dim tmpNode为XmlNode = dom.CreateElement(" Details"

dim xAtt as XmlAttribute = dom.CreateAttribute(" Name"

xatt.value ="已批准

tmpNode.attributes.append(xatt


''重复上面添加更多属性


product.appendchild tmpnod


Nex

----- Rich Wallace wrot e:----


我肯定有一种非常好吃的方法,我一直在努力工作

快速处理几件事情,并且可能正处于过度紧张的状态

这个..


我通过字符串Feed收到传入的XML文档网络服务


< Root><产品><文件>订单< / File>< Origin> OregonOffice< / Origin>< Details Name =" Product"值= QUOT;粘合剂" />< Details Name =" Qty"值= QUOT 1 QUOT; />< / Product>< / root


我需要修改传出的XML以读取批准检查的状态


< Root>< Product>< File> Order< / File>< Origin> OregonOffice< / Origin>< Details Name =" Product"值= QUOT;粘合剂" />< Details Name =" Qty"值= QUOT 1 QUOT; />< Details Name =" Approved"值= QUOT假QUOT; />< / Product>< / root


一旦我从方法调用获得了True或False值,我将如何修改

XML添加新属性


TI

-Ric

dim dom as new XmlDocumen
dom.loadxml(yourxmlstring
dim products as XmlNodeList = dom.selectnodes("descendant::product"

For each product as XmlNode in Product
dim bApproved as Boolean = GetApprovalValue() ''get your boolean flag here. for each produc
dim tmpNode as XmlNode = dom.CreateElement("Details"
dim xAtt as XmlAttribute = dom.CreateAttribute("Name"
xatt.value = "Approved
tmpNode.attributes.append(xatt

''repeat above to add more attribute

product.appendchild tmpnod

Nex
----- Rich Wallace wrote: ----

I''m sure there''s a very weasy way to do this, I''ve been running hard an
fast on several things at once and just may be at the point of overthinkin
this..

I receive an incoming XML document via a string feed within a web service

<Root><Product><File>Order</File><Origin>OregonOffice</Origin><Details Name="Product" Value="Binder" /><Details Name="Qty" Value="1" /></Product></Root

I need to modify the outgoing XML to read the status of an approval check

<Root><Product><File>Order</File><Origin>OregonOffice</Origin><Details Name="Product" Value="Binder" /><Details Name="Qty" Value="1" /><Details Name="Approved" Value="False" /></Product></Root

Once I have the True or False value from a method call, how would I modif
the XML to add the new attributes

TI
-Ric


dim dom作为新的XmlDocumen

dom.loadxml(yourxmlstring

dim products as XmlNodeList = dom.selectnodes(" descendant :: product"

$ b) $ b对于每个产品作为产品中的XmlNode

dim bApproved as Boolean = GetApprovalValue()''在这里得到你的布尔标志。对于每个产品

dim tmpNode as XmlNode = dom .CreateElement(" Details"

dim xAtt as XmlAttribute = dom.CreateAttribute(" Name"

xatt.value =" Approved

tmpNode.attributes.append(xatt


''重复上面添加更多属性


product.appendchild tmpnod


Nex

----- Rich Wallace写道:----


我肯定在那里这是一种非常可怕的方式,我已经在一些事情上快速地运行了很多东西,而且可能正好处于这个过程中。 。


我通过网络服务中的字符串Feed收到传入的XML文档


< Root>< Product>< File> ;订单< / File>< Origin> OregonOffice< / Origin>< Details Name =" Product"值= QUOT;粘合剂" />< Details Name =" Qty"值= QUOT 1 QUOT; />< / Product>< / root


我需要修改传出的XML以读取批准检查的状态


< Root>< Product>< File> Order< / File>< Origin> OregonOffice< / Origin>< Details Name =" Product"值= QUOT;粘合剂" />< Details Name =" Qty"值= QUOT 1 QUOT; />< Details Name =" Approved"值= QUOT假QUOT; />< / Product>< / root


一旦我从方法调用获得了True或False值,我将如何修改

XML添加新属性


TI

-Ric

dim dom as new XmlDocumen
dom.loadxml(yourxmlstring
dim products as XmlNodeList = dom.selectnodes("descendant::product"

For each product as XmlNode in Product
dim bApproved as Boolean = GetApprovalValue() ''get your boolean flag here. for each produc
dim tmpNode as XmlNode = dom.CreateElement("Details"
dim xAtt as XmlAttribute = dom.CreateAttribute("Name"
xatt.value = "Approved
tmpNode.attributes.append(xatt

''repeat above to add more attribute

product.appendchild tmpnod

Nex
----- Rich Wallace wrote: ----

I''m sure there''s a very weasy way to do this, I''ve been running hard an
fast on several things at once and just may be at the point of overthinkin
this..

I receive an incoming XML document via a string feed within a web service

<Root><Product><File>Order</File><Origin>OregonOffice</Origin><Details Name="Product" Value="Binder" /><Details Name="Qty" Value="1" /></Product></Root

I need to modify the outgoing XML to read the status of an approval check

<Root><Product><File>Order</File><Origin>OregonOffice</Origin><Details Name="Product" Value="Binder" /><Details Name="Qty" Value="1" /><Details Name="Approved" Value="False" /></Product></Root

Once I have the True or False value from a method call, how would I modif
the XML to add the new attributes

TI
-Ric


作品,谢谢。


有没有办法通过文档说明并确保我把它放在

的确切位置?

即:

< Root>

<产品>

<文件>订单< / File>

< Origin> OregonOffice< / Origin>

< Details Name =" Product"值= QUOT;粘合剂" />

< Details Name =" Qty"值= QUOT 1 QUOT; /> - 我想确保在Qty之后和Mfr之前放置我的新



< Details Name =" Mfr"值=" ABC Co." />

< / Product>

< / Root>


再次感谢。

-r

" tMan" <一个******* @ discussions.microsoft.com>在消息中写道

新闻:9D ********************************** @ microsof t.com ...
Works, thank you.

Is there a way to nivagiate through the doc and make sure I place it in an
exact spot?

I.e:
<Root>
<Product>
<File>Order</File>
<Origin>OregonOffice</Origin>
<Details Name="Product" Value="Binder" />
<Details Name="Qty" Value="1" /> -- I want to make sure I place my new
line after the Qty and before Mfr
<Details Name="Mfr" Value="ABC Co." />
</Product>
</Root>

Thanks again.
-r
"tMan" <an*******@discussions.microsoft.com> wrote in message
news:9D**********************************@microsof t.com...
dim dom as new XmlDocument
dom.loadxml(yourxmlstring)
dim products as XmlNodeList = dom.selectnodes(" descendant :: product")

对于每个产品,作为产品中的XmlNode
dim bApproved as Boolean = GetApprovalValue()''在这里得到你的布尔标志
。对于每个产品,dim tmpNode为XmlNode = dom.CreateElement(" Details")
dim xAtt as XmlAttribute = dom.CreateAttribute(" Name")
xatt.value =" Approved"
tmpNode.attributes.append(xatt)

''重复上面添加更多属性

product.appendchild tmpnode

下一页

----- Rich Wallace写道:-----

我肯定有一种非常好吃的方法,我一直在努力运行
并且同时快速处理几件事情,并且可能正好在
中过度思考...

我通过web $ b中的字符串提要接收传入的XML文档$ b服务:

< Root><产品><文件>订单< / File>< Origin> OregonOffice< / Origin><详情

名称= QUOT;产品与QUOT;值= QUOT;粘合剂" />< Details Name =" Qty"值=" 1"

/>< / Product>< / root>
我需要修改外发XML以读取审批状态
check :

< Root>< Product>< File> Order< / File>< Origin> OregonOffice< / Origin>< Details

Name ="产品"值= QUOT;粘合剂" />< Details Name =" Qty"值= QUOT 1 QUOT; /><详情

Name =" Approved"值= QUOT假QUOT; />< / Product>< / Root>
一旦我从方法调用获得True或False值,我将如何修改XML以添加新属性?

TIA
-Rich
dim dom as new XmlDocument
dom.loadxml(yourxmlstring)
dim products as XmlNodeList = dom.selectnodes("descendant::product")

For each product as XmlNode in Products
dim bApproved as Boolean = GetApprovalValue() ''get your boolean flag here. for each product dim tmpNode as XmlNode = dom.CreateElement("Details")
dim xAtt as XmlAttribute = dom.CreateAttribute("Name")
xatt.value = "Approved"
tmpNode.attributes.append(xatt)

''repeat above to add more attributes

product.appendchild tmpnode

Next

----- Rich Wallace wrote: -----

I''m sure there''s a very weasy way to do this, I''ve been running hard and fast on several things at once and just may be at the point of overthinking this...

I receive an incoming XML document via a string feed within a web service:
<Root><Product><File>Order</File><Origin>OregonOffice</Origin><Details
Name="Product" Value="Binder" /><Details Name="Qty" Value="1"
/></Product></Root>
I need to modify the outgoing XML to read the status of an approval check:
<Root><Product><File>Order</File><Origin>OregonOffice</Origin><Details
Name="Product" Value="Binder" /><Details Name="Qty" Value="1" /><Details
Name="Approved" Value="False" /></Product></Root>
Once I have the True or False value from a method call, how would I modify the XML to add the new attributes?

TIA
-Rich



这篇关于将新数据附加到现有XML以进行输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆