How do I get if the XElement Contains Specific children ?
Use HasElements or HasAttributes.
If you want to check for a specific set of elements, look here: Checking an XElement for Existence of One of Several Possible XElements
Related
So I am making a quest system, and I want to randomly choose a quest, but i dont want it to choose the same one again.
Here is the piece on code for the string.
I cant find any good answer.
This is a more simple line of code.
string[] QuestChoose = new string[] {"Quest1", "Quest2", "Quest3"};
3 methods come to mind:
Convert to a List and call Remove().
Write null into the array after having read the quest and when selecting a quest, always search for the next suggestion if null was selected.
Keep a separate data structure like a HashSet<int> where you add the index in the array whenever a quest has been used. Then check for Contains on your ID when selecting.
You really ought to use lists if you want to dynamically add/remove elements from your set.
Instead of:
string[] QuestChoose = new string[] {"Quest1", "Quest2", "Quest3"};
try using:
List<string> QuestChoose = new List<string> { "Quest1", "Quest2","Quest3"};
You can add elements by calling QuestChoose.Add("Quest4");
Or remove an element by calling: QuestChoose.Remove(ItemNumber);
Where as "ItemNumber" is the index of the string you want to remove. For example; Calling QuestChoose.Remove(0); will remove the first item in the list, which in this case would be "Quest1"
We are using react-select component in one of our projects and trying to resolve accessibility issues. Right now, there is no way to provide the required aria attributes to the input element which has the aria-autocomplete="list" attribute.
https://www.digitala11y.com/aria-autocomplete-properties/
Above is the reference link to what we are trying to achieve. Below is the short story from the above link.
If an element has aria-autocomplete set to list or both, authors MUST ensure both of the following conditions are met:
The element has a value specified for aria-controls that refers to the element that contains the collection of suggested values.
Either the element or a containing element with role combobox has a value for aria-haspopup that matches the role of the element that contains the collection of suggested values.
I opened a PR to add the ability to add ARIA properties to the input element. https://github.com/JedWatson/react-select/pull/4132
But I wanted to check if I'm missing something if anyone has already worked on this. Please let me know if you need any other details.
I have few short questions regarding Enterprise architect.
My question is regarding the automation interface. When following the instructions provided on this page: http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/colle... in order to add a new element to the collection ( and the .eap file) it does not add the element. I can get data from the elements, modify and even delete them, but adding a new element does not work?
Instructions provided:
Call AddNew to add a new item.
Modify the item as required.
Call Update on the item to save it to the database.
Call Refresh on the collection to include it in the current set.
my java example:
elements is a collection of all the elements in the model...
org.sparx.Element elementEa = elements.AddNew("Requirement", "non-functional");
elementEa.Update();
elements.Refresh();
With the api is it possible to change the id or guid of an element since there are no methods specified in org.sparx for that?
One last thing... Is it possible to create a custom element in EA, for example a requirement which will not have the standard properties like difficulty, priority etc.. , but will have others? (normal properties, not tagged values)
The arguments to AddNew() are Name and Type, so to create a Requirement element you should specify "SomeRequirementName" and "Requirement".
You can't change the ID or GUID through the API, and your models would crash and burn if you did (connectors would be left dangling, elements would vanish from diagrams, etc, etc).
With an MDG Technology you can create very detailed stereotyped elements if you like, with their own visual representations (shape scripts) etc, but if you're after creating an element type with its own properties dialog the answer is no; there is no hook for a custom dialog in the API.
Collection<Package> packageCollection = myPackage.GetPackages();
Package consolidatedCfsSpecPackage = packageCollection.AddNew("somePackageName", "");
if (!consolidatedCfsSpecPackage.Update()) {
System.err.println("Not Updated: somePackageName");
}
packageCollection.Refresh();
This works for me. I suggest you to check return value of elementEa.Update() method you called. If it returns false, you can get the reason by calling elementEa.GetLastError().
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.
I'm having a hard time testing our Wicket application using Selenium because of the random markup ids.
For individual elements, I can use abc.setOutputMarkupId(true).setMarkupId("myId")
to set their markup id explicitly.
But what if the element is added dynamically using a repeater (like ListView)? Is there a way to specify how the markup id sequence should look like?
Well, can't you do the same thing with ListView? If you make your own ListView implementation, and then in the populateItem(final ListItem<?> listItem) method, on that respective listItem you do:
listItem.setOutputMarkupId(true); // write id attribute of element to html
listItem.setMarkupId("id"+i);
where i is some index you initialize in the ListView's constructor or something?
as Andrei told that its possible but dangerous.
setMarkupId doc:
Retrieves id by which this component is represented within the markup. This is either the id attribute set explicitly via a call to
org.apache.wicket.Component.setMarkupId(java.lang.String), id
attribute defined in the markup, or an automatically generated id - in
that order. If no explicit id is set this function will generate an id
value that will be unique in the page. This is the preferred way as
there is no chance of id collision.
http://www.kiwidoc.com/java/l/p/org.apache.wicket/wicket/1.4.0/p/org.apache.wicket/c/Component#top
and also you cant get the markup id with getMarkupId()