Easiest Way to Modify XML Attribute?

B

beachnut

Hi, all.

I am passed an XML chunk via a string parameter,
which I must parse to get some attribute values,
run some computation on those, poke the result
into another attribute, and return that chunk
to the caller with only the result changed.

I was messing with MemoryString and XMLReader,
but maybe SAX isn't the way to go?

What's the best way to do this?

Thanks in advance!

bn
 
H

Hans Kesting

beachnut said:
Hi, all.

I am passed an XML chunk via a string parameter,
which I must parse to get some attribute values,
run some computation on those, poke the result
into another attribute, and return that chunk
to the caller with only the result changed.

I was messing with MemoryString and XMLReader,
but maybe SAX isn't the way to go?

What's the best way to do this?

Thanks in advance!

bn

I think you want XmlDocument.
Use an XPath query in SelectSingleNode to select what you want:
either directly the argument you want
or the node possibly containing the argument (then use the Arguments
collection to find your argument)

Hans Kesting
 
M

Martin Honnen

beachnut wrote:

I am passed an XML chunk via a string parameter,
which I must parse to get some attribute values,
run some computation on those, poke the result
into another attribute, and return that chunk
to the caller with only the result changed.

I was messing with MemoryString and XMLReader,
but maybe SAX isn't the way to go?

XmlReader is not SAX but anyway,
What's the best way to do this?

if you want to parse, modify and save XML then XmlDocument is the right
solution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top