By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,289 Members | 1,260 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,289 IT Pros & Developers. It's quick & easy.

Append new data to existing XML for output?

P: n/a
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
Nov 12 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
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

Nov 12 '05 #2

P: n/a
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

Nov 12 '05 #3

P: n/a
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")

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

Nov 12 '05 #4

P: n/a
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")

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

Nov 12 '05 #5

P: n/a
Can anybody assist? I'm not sure where to look in MSDN or online help, I
can't seem to find what I'm looking for.

"Rich Wallace" <ri**********@minusthecannedmeat.jfsheadotcom> wrote in
message news:OP**************@tk2msftngp13.phx.gbl...
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")

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


Nov 12 '05 #6

P: n/a
Can anybody assist? I'm not sure where to look in MSDN or online help, I
can't seem to find what I'm looking for.

"Rich Wallace" <ri**********@minusthecannedmeat.jfsheadotcom> wrote in
message news:OP**************@tk2msftngp13.phx.gbl...
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")

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


Nov 12 '05 #7

P: n/a
Rich:
in xml, the order of the child nodes (or attributes of a node) does not really matter. (atleast it shouldn't)
you can use the prependchild() method to append a child as a first child to a node.

google for more samples if you absolutely have to have the node at a particular position.

"Rich Wallace" wrote:
Can anybody assist? I'm not sure where to look in MSDN or online help, I
can't seem to find what I'm looking for.

"Rich Wallace" <ri**********@minusthecannedmeat.jfsheadotcom> wrote in
message news:OP**************@tk2msftngp13.phx.gbl...
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")

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



Nov 12 '05 #8

P: n/a
Rich:
in xml, the order of the child nodes (or attributes of a node) does not really matter. (atleast it shouldn't)
you can use the prependchild() method to append a child as a first child to a node.

google for more samples if you absolutely have to have the node at a particular position.

"Rich Wallace" wrote:
Can anybody assist? I'm not sure where to look in MSDN or online help, I
can't seem to find what I'm looking for.

"Rich Wallace" <ri**********@minusthecannedmeat.jfsheadotcom> wrote in
message news:OP**************@tk2msftngp13.phx.gbl...
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")

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



Nov 12 '05 #9

P: n/a
Thanks for the info.

"tMan" <tM**@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
Rich:
in xml, the order of the child nodes (or attributes of a node) does not really matter. (atleast it shouldn't) you can use the prependchild() method to append a child as a first child to a node.
google for more samples if you absolutely have to have the node at a particular position.
"Rich Wallace" wrote:
Can anybody assist? I'm not sure where to look in MSDN or online help, I can't seem to find what I'm looking for.

"Rich Wallace" <ri**********@minusthecannedmeat.jfsheadotcom> wrote in
message news:OP**************@tk2msftngp13.phx.gbl...
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")
>
> 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
>
>
>


Nov 12 '05 #10

P: n/a
Thanks for the info.

"tMan" <tM**@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
Rich:
in xml, the order of the child nodes (or attributes of a node) does not really matter. (atleast it shouldn't) you can use the prependchild() method to append a child as a first child to a node.
google for more samples if you absolutely have to have the node at a particular position.
"Rich Wallace" wrote:
Can anybody assist? I'm not sure where to look in MSDN or online help, I can't seem to find what I'm looking for.

"Rich Wallace" <ri**********@minusthecannedmeat.jfsheadotcom> wrote in
message news:OP**************@tk2msftngp13.phx.gbl...
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")
>
> 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
>
>
>


Nov 12 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.