xml + xmlreader + xmlwrite ?

  • Thread starter Thread starter C# newbie
  • Start date Start date
C

C# newbie

Hi,

I'm supposed to write a class to do search (using XPath queries) into an XML
file, also capturing attribute information & elements + ability to modify
information too.
Here is my question: Can I create a class which contains System.Xml and
XmlTextReader + XTextWriter classes ?
I mean, does it make sense to have all these stuff in one class together ?

Thanks in advance for your suggestions
Newbie
 
I'm not sure why you'd do this.

The simplest route for basic XPath operations is to create an instance of
the XmlDocument class and call LoadXml on it, passing in the XML as a
string. XPath operations can then be performed by calling SelectNodes or
SelectSingleNode on the XmlDocument object.

If you need to do more advanced XPath operations, consider using the
XPathNavigator class in the System.Xml.XPath namespace.

--
 
Hi Doug,

Thanks for your quick response! the thing is I'm not familiar with
XPathNavigator however, I"m going to focus on it. Hope it does what I need
like retreiving element, attributes and stuff like that.
Anyhow thanks for your help.

Regards
Newbie

Doug Erickson said:
I'm not sure why you'd do this.

The simplest route for basic XPath operations is to create an instance of
the XmlDocument class and call LoadXml on it, passing in the XML as a
string. XPath operations can then be performed by calling SelectNodes or
SelectSingleNode on the XmlDocument object.

If you need to do more advanced XPath operations, consider using the
XPathNavigator class in the System.Xml.XPath namespace.

--
----
Doug Erickson [MSFT], Platform SDK UA
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2003 Microsoft Corporation. All rights
reserved.


C# newbie said:
Hi,

I'm supposed to write a class to do search (using XPath queries) into an XML
file, also capturing attribute information & elements + ability to modify
information too.
Here is my question: Can I create a class which contains System.Xml and
XmlTextReader + XTextWriter classes ?
I mean, does it make sense to have all these stuff in one class together ?

Thanks in advance for your suggestions
Newbie
 
regarding your advice I'm reading some text about XPahtNavigator but it
doesn't give me any editing capabilities! it provides read only view of an
xml file. I need to modify some text within a searched xml file.

any suggestions ?

thanks

Doug Erickson said:
I'm not sure why you'd do this.

The simplest route for basic XPath operations is to create an instance of
the XmlDocument class and call LoadXml on it, passing in the XML as a
string. XPath operations can then be performed by calling SelectNodes or
SelectSingleNode on the XmlDocument object.

If you need to do more advanced XPath operations, consider using the
XPathNavigator class in the System.Xml.XPath namespace.

--
----
Doug Erickson [MSFT], Platform SDK UA
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2003 Microsoft Corporation. All rights
reserved.


C# newbie said:
Hi,

I'm supposed to write a class to do search (using XPath queries) into an XML
file, also capturing attribute information & elements + ability to modify
information too.
Here is my question: Can I create a class which contains System.Xml and
XmlTextReader + XTextWriter classes ?
I mean, does it make sense to have all these stuff in one class together ?

Thanks in advance for your suggestions
Newbie
 
Back
Top