Skip to content

Simple implementation for a querySelector function for XML documents.

License

Notifications You must be signed in to change notification settings

vectorderivative/QueryCSelector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

QueryCSelector

Simple C# implementation for a querySelector JQuery-ish function for XML documents. Mainly this is a XElement wrapper that solves some issues related to working with namespaces.

QuerySelector QS = New QuerySelector();
  QS.CreateFromFile("GetMemberResponse.xml");
  //Use Xpath expressions
  QS.Select("vouchersList/voucher/productId").GetElement(2).Text("test");
  Console.WriteLine(QS.Render());

Methods

Create loads the XML string, XElement or XElements object.

Select executes an XPath expression to query the document.

GetElement(i) gets the QuerySelector object for the i node from a collection of nodes result of a previous selection.

GetXElement(i) gets the selected node as a XElement object

Length gets the number of nodes resulting from a selection.

Text same as JQuery function.

Attr gets or sets attributes.

Append Appends a node to the selected element, optionally it takes a second argument as the new node content

Prepend Prepends a node to the selected element, optionally it takes a second argument as the new node content

After Adds a node after the selected element, optionally it takes a second argument as the new node content

Before Adds a node before the selected element, optionally it takes a second argument as the new node content

Remove Removes the selected node

Clear Clears the selected node content

Render ToString method.

Additional info

This is just an alpha proof of concept to get simple things done quick (get/set node values and attributes)

Namespaces are ignored

About

Simple implementation for a querySelector function for XML documents.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published