public void PrependsProcessingInstructionsToDomRoot() { var dom = new Xambler( new Yaapii.Atoms.Enumerable.ManyOf <IDirective>( new PiDirective("alpha", "beta \u20ac"), new AddDirective("x4") ) ).Dom(); Assert.Equal( "<?alpha beta €?><x4 />", dom.ToString(SaveOptions.DisableFormatting) ); }
public void NavigatesFromRootAfterDeletedNode() { var xml = XDocument.Load(new InputOf("<root><child name='Jerome'><property name='test'/></child></root>").Stream()); var xambler = new Xambler( new Directives() .Xpath("/root/child[@name='Jerome']/property[@name='test']") .Remove() // Node will be deleted. After this operation the cursor points to the parent nodes. .Xpath("/root/child[@name='Jerome']") .Add("property") .Attr("name", "test2") ).Apply(xml); Assert.Equal( "<root><child name=\"Jerome\"><property name=\"test2\" /></child></root>", xambler.ToString(SaveOptions.DisableFormatting) ); }
public void AddsProcessingInstructionsDirectlyToDom() { var dom = new Xambler( new Yaapii.Atoms.Enumerable.ManyOf <IDirective>( new AddDirective("xxx") ) ).Dom(); new PiDirective("x", "y").Exec( dom, new DomCursor( new List <XNode>() ), new DomStack() ); Assert.Equal( "<?x y?><xxx />", dom.ToString(SaveOptions.DisableFormatting) ); }