How could i add all xml element names (distinct) to a dictionary with xml.etree.cElementTree.iterparse - celementtree

def count_tags(osm_file):
found = {}
for event, elem in ET.iterparse(osm_file):
Id like to get with xml.etree.cElementTree.iterparse form a huge file the xml root and the top level tags and add them disticnt to a dict. May there someone could help me please.

Related

Get current index of for tag in jsrender

Is there any way to get the current index of for tag in the tag.
Need an solution
{{for ~ID=#index}}
{{:~ID}}
{{/for}}
It will not work because #index is accessible only within the for loop.
Working Code:
{{for}}
{{:#index}}
{{/for}}
And is there any way to access the Jsonobject key and value in for tag instead of prop tag.
{{for arrayOfObj}}
{{:#data.key}} //In here data is a jsonobject.
//I need an key and value of this object.
{{/for}}
Thanks in advance.
Your question isn't very clear. You have an array of objects - OK so what do you want to do?
If you want to iterate over the array you can write {{for arrayOfObj}}...{{/for}}.
Now, inside that block you can get the index and the object. If you want to get a specific known key (if you know the object has a name property for example) you can write {{:name}}.
But if you want to iterate over all of the properties of each object, you can use {{props}} (for each object, within the {{for}} block):
{{for arrayOfObj}} - iterate over array
{{:#index}} - this is the index in the array
{{:name}}
{{props}} - iterate over props of this object
{{:key}}
{{:prop}}
{{:#getIndex()}} - this is the index in the array
{{/props}}
{{/for}}

Open XML iterated table binding to word document

I have to bind iterated tables to word document using open xml. I.I can able to bind single table to word document.
i am able to bind single table header 1 shown in image using book mark.
Could you please provide some ideas to bind multiple tables dynamically.Here in above image header 1 ,header 2 are dynamic ..IT may goes until header N..
Can any one provide some ideas to how to proceed on this .
I think you are looking for something like this -
foreach(HeaderPart headerPart in docGenerated.MainDocumentPart.HeaderParts)
{
foreach(Table table in headerPart.Header.Descendants<Table>())
{
// do whatever you want to do with your table.
}
}

In CQ How disable the topmost node of a tag

Is there any way to disable the topmost node of a tag when I am adding a tag.
It is like suppose I have a dialog in which there is a field with xtype= tags and the tag is XYZ under which A, B, C are child nodes.
I want the author to select only A or B or C. He can not select XYZ.
How can I implement this. in the tagging_field.js
Thanks.
Sorry for replying after long time, this might be helpful for others. This can be achieved something like this, if the user/author selects xyz tag the value gets added to the tag field, you can get the array of values added in the tag field using getValue method and if the array contains the xyz value delete the value and setValue back to the tag field using setValue method
Here is the link to API docs for tag field for you to refer. Tag Field API Docs
Regards,
Yash Ahuja.

How to add elements to a root using org.w3c.Dom

I am using Org.W3c.dom for generating and parsing XML files in my app.
Here I am stuck because I can not find a way to add more elements to a Root element.
I want to generate Xml as below :
<root>
<siteDesc>abc</siteDesc>
<respCode>false</respCode>
<respMsg>Done</respMsg>
</root>
Here is the code which I am using to generate XML File ...
private final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
Element responseElement = document.createElementNS(NAMESPACE_URI, "root");
responseElement.appendChild("TODO") // Confused Here .. How to append elements with their names
Can anyone suggest me, Here In above code .. What are the required changed to add elements to the roor node ????
You want to
create a node and add that to your document (responseElement)
create further Elements and add those to your responseElement (again, using appendChild())
for each of these, create a TextNode and add those to your Elements
In the above, the element creation is distinct from the addition to the document.

how to create group of gwt Order list

Hi,
My goal is to create a list of items in GWT similar to how it is done in HTML using ordered and unorderd lists. Can someone explain to me how this can be achieved in GWT?
Thanks!!
you can use the dom API in com.google.gwt.dom.client which has a syntax very close from the JavaScript one:
for (String listItem : listData) {
LIElement liElement = Document.get().createLIElement();
liElement.setInnerText(step);
this.olElement.appendChild(liElement);
}
this example simply add the list item build from the listData List end append them in the ordered list. I used UiBinder to get the olElement so you have to get a root element somewhere (Document has a method getElementById) and add your Element to it.