XML reader/write

  • Thread starter Thread starter ba.hons
  • Start date Start date
B

ba.hons

Hello.

I have built a windows service that has a filewatcher object, which
checks when any XML files have been created or deleted from a certain
directory.


My problem now is i have to get involved with the XML ! which am new
at!

So when i receive the file, currently am just logging in this, i need
to read and parse it and then construct a very similar XML and place it
back in this directory.

What would be the best way to approach this?

Any help really would be appreciated

thanks

Paul
 
ba.hons said:
So when i receive the file, currently am just logging in this, i need
to read and parse it and then construct a very similar XML and place it
back in this directory.

What would be the best way to approach this?

That depends on your skill set and on the resources you have. XSLT is a
transformation language that is nice for transforming XML to XML. .NET
1.x supports XSLT 1.0 with System.Xml.Xsl.XslTransform, .NET 2.0 also
supports XSLT 1.0 but with System.Xml.Xsl.XslCompiledTransform.

There are other ways, you can read your XML into a
System.Xml.XmlDocument and the manipulate the DOM (document object
model) to add/change/delete nodes and save the DOM back to a file.

It is also possible to read in XML with an XmlReader and write it out
with an XmlWriter. That is usually more work than using XSLT or DOM but
performs better with large XML documents as both DOM and XSLT build a
tree model of the complete XML document in memory.
 
If you want to construct a similar XML, you can use the DOM to load and save
it to a different file or rather copy the same file to a new location.
Since you are watching all the XMLs created, you will have to know the
structure of all the XMLs to derive meaning out of it.

If you are looking for a specific tag in an XML then you could use the
search functionality in DOM.

Cheers
Ramananda
 
Back
Top