How to add a new node to root node in XML document using Libxml2 that should be first element - libxml2

I am using Libxml2 Every time i am adding new nodes to the existing XML document. Adding new nodes is fine but what ever i added nodes in the XML document it added last of the child node but i want to add new nodes after the root node.

Once you've created your new node, you can get use xmlAddPrevSibling on the current first child of the root to get your new node inserted "before" the current first child.

Related

Get parent page node for component in magnolia

I configured a listener in the magnolia observation module that uses info.magnolia.module.observation.commands.RestrictToNodeTypeEventListener for mgnl:component node type. When a NODE_ADDED, NODE_MOVED, NODE_REMOVED, PROPERTY_ADDED, PROPERTY_CHANGED and PROPERTY_REMOVED event happens on the mgnl:component it triggers a custom command class.
In the custom command class the node is of type mgnl:component and the path is for example: node at path /aalongpubname/de/test-page-for-observer/content/01 but I need to get the parent mgnl:page node for it (ie. /aalongpubname/de/test-page-for-observer). The component could also be nested ie. not at the first level. What is the easiest way to do this?
I believe one of the way to do this is: NodeUtil.getNearestAncestorOfType(node,"mgnl:page").getName()

Obtaining path of associated documents in custom model in Alfresco

I have an association in custom model in alfresco as has been mentioned in the post:
How do I associate one piece of content with another in Alfresco?
For properties, to get the name of the property I am using:
var model = document.properties["sc:itemNo"];
How can I obtain the name and path where this image resides in the repository, using JavaScript.
Thanks!
Assuming document has an association named sc:sampleAssoc and there is at least one association exsting for that node, you will get its full qname path like so:
var qNameOfAssocatiatedNode = document.assocs["sc:sampleAssoc"][0].qnamePath;
Be clear though that there may be more than one node at that path.

How to Upgrade a newly added property in all existing nodes?

We are managing an umbraco site which has over 2000 nodes .We have recently added a new property in one of our master document type,since it is a new property the existing nodes doesn't have the property value .We have to update the value of that property in each node before deploying the new changes.It is very difficult to update the values manually since it takes a lot of time.What we are planning is to use a one time upgrade aspx page or user control to accomplish this job. has anyone ever been into this kind of a situation ?how to make a one time upgrade page ? Any help would be appreciated .
I fairly sure that this isn't in the core and that there hasn't been a package created for exactly this purpose. But it's pretty simple to create a macro containing a razor (cshtml) script that updates a single property for all the descendants of a particular node:
Something like (just from memory of the Level 2 course):
var nodes = #Model.DescendantsOrSelf(-1); //-1 is the root node
foreach (var node in nodes)
{
Document doc = new Document(node.Id);
doc.getProperty("yourProperty").Value = "xxx"; // the getProperty looks wrong, I know
doc.Publish(new User(0)); //User 0 is the admin user
umbraco.library.UpdateDocumentCache(doc.Id);
}
This great package http://our.umbraco.org/projects/developer-tools/content-maintenance-dashboard-package does mass updating, but last time I checked it didn't update single fields - but it might do by now.
I would have thought doing a republish of the xml cache should do this if you go to the following url:
/umbraco/dialogs/republish.aspx?xml=true

Dynamic TreeView user Control

I am working on a page with Treeview properties. This page has set of html links which looks as following:
1.Parent
1.1 child
1.2 child
1.2.1 grandchild ....
I generate this page by dynamically loading a xml file. Now I want to provide user with an option to add parent/ child links on the UI, and update the database and XML file soon user makes any changes.
I am clueless about how to proceed for this problem. Please provide me any references or hints to do this.Thank you
I'm assuming your binding your treeview to a XML file, like this: http://social.msdn.microsoft.com/forums/en-US/xmlandnetfx/thread/7fc1c90f-7004-4ffd-829b-facd05f6135d
Then when a user adds a node you should add it to the XML and then save the XML file.
Dim doc As New XmlDocument()
doc.Load("doc.xml")
Now you have the XML stored in a XmlDocument member variable, simply write a method to add nodes e.g.
Sub AddNode(ByVal name As String)
Dim nameEl As XmlElement = doc.CreateElement("name")
nameEl.InnerText = name
doc.DocumentElement.AppendChild(nameEl)
End Sub
Then save changes later with e.g.
doc.Save("doc.xml")
I finished working on this problem ! it works fine now :) I created crud methods in business layer to do this

Create new node references for the node reference field

Is there a module besides http://drupal.org/project/noderefcreate that allows a full from to be popped up/embedded to create a new node reference from a node reference field?
I don't know the purpose of your question but this may be a workaround :
http://drupal.org/project/field_collection
If you are under D6 you can also try CCK 3.0 and its Multigroup submodule

Resources