title: How to create a directory on the basis of path in cq5?
body: <p>I have a String which is the path of the page for example <code>/content/xperia/public/events/eventeditor</code>. I am gererating the XML of this page and saving it to DAM, but I want to save it in the similar tree structure under <code>/content</code>. </p>
  
  <p>I tried the following code 
  </p>
  
  <pre><code>String page = "/content/xperia/public/events/eventeditor";
  page = page.replace("/content", "/content/dam");
  if (adminSession.nodeExists(page+ "/"+ "jcr:content")) {
      Node node = adminSession.getNode(page+ "/"+ "jcr:content");
      node.setProperty("jcr:data", sb.toString());                
  } else {
      Node feedNode = JcrUtil.createPath(page,"nt:file", adminSession);           
      Node dataNode = JcrUtil.createPath(feedNode.getPath() + "/"+ "jcr:content", "nt:resource", adminSession);       
      dataNode.setProperty("jcr:data",sb.toString());
  }
  </code></pre>
  
  <p>But it gives the following error </p>
  
  <blockquote>
    <p>No matching child node definition found for
    {<a href="http://www.jcp.org/jcr/1.0" rel="nofollow">http://www.jcp.org/jcr/1.0</a>}content</p>
  </blockquote>
  
  <p>Because there is no such path in the repository. Is there a way through which I can create a directory on the fly. Because to save this file, I need to create  the entire tree <code>xperia/public/events</code> under <code>/content/dam</code> and then save <code>eventeditor.xml</code> in that directory .</p>
  
  <p>Please suggest.</p>