How to get value of particular name in xml file - ruby-on-rails

<ecomexpress-objects version="1.0">
<object pk="1" model="awb">
<field type="BigIntegerField" name="awb_number">700054480</field>
<field type="CharField" name="orderid">5012</field>
<field type="FloatField" name="actual_weight">0.5</field>
<field type="CharField" name="origin">DELHI-DSW</field>
<field type="CharField" name="destination">DELHI-DLN</field>
<field type="CharField" name="customer">Ecom Express Private Limited - 32012</field>
<field type="CharField" name="consignee">MUKESH KUMAR GUPTA</field>
<field type="CharField" name="pickupdate">11-Feb-2013</field>
<field type="CharField" name="status">Delivered / Closed</field>
<field type="CharField" name="reason_code"/>
<field type="CharField" name="reason_code_description"/>
<field type="CharField" name="reason_code_number">999</field>
<field type="CharField" name="receiver">mukesh 9999488339</field>
<field type="CharField" name="expected_date">12-Feb-2013</field>
<field type="CharField" name="last_update_date">05-Apr-2013</field>
<field type="CharField" name="delivery_date">2013-02-17 11:26:00</field>
<field type="CharField" name="ref_awb">None</field>
<field type="CharField" name="rts_shipment"/>
<field type="CharField" name="system_delivery_update">2013-02-17 11:26:00 </field>
<field type="CharField" name="rts_system_delivery_status"/>
<field name="scans">
<object pk="1" model="scan_stages">
<field type="DateTimeField" name="updated_on">05 Apr, 2013, 19:40 hrs</field>
<field type="CharField" name="status">SAL Tally closed</field>
<field type="CharField" name="reason_code"/>
<field type="CharField" name="reason_code_number"/>
<field type="CharField" name="location">DLN</field>
<field type="CharField" name="Employee">Umesh Jaswanti - 10015</field>
</object>
<object pk="2" model="scan_stages">
<field type="DateTimeField" name="updated_on">05 Apr, 2013, 19:39 hrs</field>
<field type="CharField" name="status">SAL Tally closed</field>
<field type="CharField" name="reason_code"/>
<field type="CharField" name="reason_code_number"/>
<field type="CharField" name="location">DLN</field>
<field type="CharField" name="Employee">Umesh Jaswanti - 10015</field>
</object>
</field>
</object>
</ecomexpress-objects>
i know the simple file xml file like
<HEUREKA>
<CATEGORY>
<CATEGORY_ID>971</CATEGORY_ID>
<CATEGORY_NAME>Auto-moto</CATEGORY_NAME>
</CATEGORY>
<CATEGORY>
<CATEGORY_ID>881</CATEGORY_ID>
<CATEGORY_NAME>Alkohol testery</CATEGORY_NAME>
<CATEGORY_FULLNAME>Heureka.cz | Auto-moto | Alkohol testery</CATEGORY_FULLNAME>
</CATEGORY>
</HEUREKA>
how to read itand get particular value but in first case i want to get status = 'Delivered / Closed'
how can i get it..
of it is there any tutorial to read the file any get the value then please share with me

I think you should try Nokogiri gem.

Related

How to set a default field value in some form view in Odoo?

How to set default value in Job_id in this form with xml and don't need to set in the python file?
<record id="form_student_stu" model="ir.ui.view">
<field name="name">Student Info</field>
<field name="model">youth_and_scholarship.youth_and_scholarship</field>
<field name="arch" type="xml">
<form string="Job Form" version="9.0">
<div class="widget_box">
<div class="widget_title"><h5>Student Information</h5></div>
<div>
<group col="1">
<field name="image" widget="image" class="oe_avatar oe_left" nolabel="1"/>
<field name="Job_id" invisible="1"/>
</group>
<group>
<field name="Kname" placeholder="First Name and Last Name..." string="Name in Khmer" style="width:40%%"/>
<field name="Ename" placeholder="First Name and last Name..." string="Name in Latin" style="width:40%%"/>
<field name="Gender" string="Gender" style="width:40%%"/>
<field name="DOB" string="Date of birth"/>
<field name="Job_work" string="Accupation" style="width:40%%"/>
</group>
</div>
</div>
</form>
</field>
</record>
You can use some context specifying an XML ID (External ID). You can add the default value to the action which calls the view like this:
<record id="youth_and_scholarship_youth_and_scholarship_action" model="ir.actions.act_window">
<field name="name">Student Info</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">youth_and_scholarship.youth_and_scholarship</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{'default_job_id': ref('xml_id')}</field>
</record>
If you open the view from a field, from a many2one for example, you can add the context to that field:
<field name="field_name" context="{'default_job_id': ref('xml_id')}" />
If haven't set the XML ID of the record you can get the ID by Python code and return an action window with the context:
job_id = self.get_job_id()
return {
'name': 'Student Info',
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'youth_and_scholarship.youth_and_scholarship',
'context': {'default_job_id': job_id }
}
NOTES:
The key always has to be: default_ + field_name: database_id
You can see all the XML IDs here: Settings > Technical > Sequences & Identifiers > External Identifiers > Complete ID

Quickfixj 1.5.x/1.6.x custom message with repeating group - compilation issue

i am trying to add a custom message and compile quickfixj and am running into an issue where last few fields that i've added are not being picked up (they all have field number > 93000 if it matters)
code generation is ok but compilation fails, i am sure i am missing something obvious, searched for similar issues reported by others but didn't find any, can someone please help
#
public static class NoAccounts extends Group {
static final long serialVersionUID = 20050617;
private static final int[] ORDER = {1, 51006, 90002, 90003, 51005, 90001, 93000, , , , , , , 0};
#
Here is what i've added
<message name="GetAccountsRsp" msgtype="UsE" msgcat="app">
<field name="RequestId" required="Y"/>
<field name="ResponseStatus" required="N"/>
<field name="ErrorMessage" required="N"/>
<component name="AccountGrp" required="N"/>
<field name="Bookmark" required="N"/>
<field name="LastFragment" required="Y"/>
</message>
<component name="AccountGrp">
<group name="NoAccounts" required="N">
<field name="Account" required="N"/>
<field name="RiskNodeID" required="N"/>
<field name="Name" required="N"/>
<field name="AutomaticMoveAccountId" required="N"/>
<field name="Owner" required="N"/>
<field name="JSCCAccountType" required="N"/>
<component name="AccountExtension" required="N"/>
</group>
</component>
<component name="AccountExtension">
<field name="JpxAccountType" required="N"/>
<field name="IsOmnibus" required="N"/>
<field name="IsGross" required="N"/>
<field name="ClientId" required="N"/>
<field name="TradingMemberId" required="N"/>
<field name="ClearingMemberId" required="N"/>
<field name="IsConcentration" required="N"/>
</component>
<field number="50007" name="Bookmark" type="STRING"/>
<field number="50025" name="RequestId" type="STRING"/>
<field number="51005" name="Owner" type="STRING"/>
<field number="51006" name="RiskNodeID" type="STRING"/>
<field number="51009" description="ClearingMemberId" type="STRING" />
<field number="51011" description="TradingMemberId" type="STRING" />
<field number="51015" name="ResponseStatus" type="STRING">
<value enum="0" description="ACCEPTED" />
<value enum="1" description="REJECTED" />
</field>
<field number="51016" name="ErrorMessage" type="STRING"/>
<field number="51019" name="NoAccounts" type="NUMINGROUP"/>
<field number="90001" name="JSCCAccountType" type="STRING">
<value enum="1" description="DEFAULT_CLEARING_HOUSE" />
<value enum="2" description="CLEARING_HOUSE" />
<value enum="3" description="NORMAL" />
<value enum="4" description="CONCENTRATION" />
</field>
<field number="90002" name="Name" type="STRING"/>
<field number="90003" name="AutomaticMoveAccountId" type="STRING"/>
<field number="93000" name="JpxAccountType" type="STRING">
<value enum="1" description="HOUSE_ACCOUNT_TYPE" />
<value enum="2" description="AFFILIATE_ACCOUNT_TYPE" />
<value enum="3" description="CLIENT_ACCOUNT_TYPE" />
</field>
<field number="93001" description="IsOmnibus" type="BOOLEAN">
<value enum="N" description="FALSE"/>
<value enum="Y" description="TRUE"/>
</field>
<field number="93002" description="IsGross" type="BOOLEAN">
<value enum="N" description="FALSE"/>
<value enum="Y" description="TRUE"/>
</field>
<field number="93003" description="ClientId" type="STRING" />
<field number="93015" description="IsConcentration" type="BOOLEAN">
<value enum="N" description="FALSE"/>
<value enum="Y" description="TRUE"/>
</field>
<field number="96005" name="ContractPeriod" type="INT"/>
please ignore, stupid error, I've added 'description' attribute instead of 'name' attribute to the new fields I've added, when I include in group/component source is generated without these causing an issue during compilation. lesson learned - double check dictionary to avoid issues during recompilation

error 400 bad request with XEP-0055?

I got possible fields from my server:
<iq xmlns="jabber:client" from="vjud.company.com" to="testuser#company.com/iPhone" id="search1" type="result"><query xmlns="jabber:iq:search">
<instructions>You need an x:data capable client to search</instructions>
<x xmlns="jabber:x:data" type="form">
<title>Search users in vjud.company.com</title>
<instructions>Fill in the form to search for any matching Jabber User (Add * to the end of field to match substring)
</instructions>
<field type="text-single" label="User" var="user"/>
<field type="text-single" label="Full Name" var="fn"/>
<field type="text-single" label="Name" var="first"/>
<field type="text-single" label="Middle Name" var="middle"/>
<field type="text-single" label="Family Name" var="last"/>
<field type="text-single" label="Nickname" var="nick"/>
<field type="text-single" label="Birthday" var="bday"/>
<field type="text-single" label="Country" var="ctry"/>
<field type="text-single" label="City" var="locality"/>
<field type="text-single" label="Email" var="email"/>
<field type="text-single" label="Organization Name" var="orgname"/>
<field type="text-single" label="Organization Unit" var="orgunit"/>
</x>
</query>
</iq>
Suppose I want to search a user with JID admin#company.com
Composed request wil look like this:
XMPPIQ *iq2 = [[XMPPIQ alloc] init];
[iq2 addAttributeWithName:#"type" stringValue:#"set"];
[iq2 addAttributeWithName:#"from" stringValue:#"testuser#company.com"];
[iq2 addAttributeWithName:#"to" stringValue:#"vjud.company.com"];
[iq2 addAttributeWithName:#"id" stringValue:#"search1"];
XMPPElement *query2 = [XMPPElement elementWithName:#"query"];
[query2 setXmlns:#"jabber:iq:search"];
XMPPElement *user = [XMPPElement elementWithName:#"user"];
[user setStringValue:#"admin"];
[iq2 addChild:query2];
[query addChild:user];
The error stanza:
<iq xmlns="jabber:client" from="vjud.company.com" to="testuser#company.com/iPhone" type="error" id="search1">
<query xmlns="jabber:iq:search"/>
<error code="400" type="modify">
<bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
</error>
</iq>
So, basically there are 2 questions:
Why there is no </query> element in response?
Is it the actual reason of the error?
-The server's response should look like this-
Big thanks to #legoscia user, in case request was composed right, you will get something like this(notice <item> element):
<iq xmlns="jabber:client" from="vjud.company.com" to="testuser#company.com/iPhone" id="search1" type="result»>
<query xmlns="jabber:iq:search"><x xmlns="jabber:x:data" type="result»>
<title>Search Results for vjud.company.com</title>
<reported>
<field type="text-single" label="Jabber ID" var="jid»/>
<field type="text-single" label="Full Name" var="fn»/>
<field type="text-single" label="Name" var="first»/>
<field type="text-single" label="Middle Name" var="middle»/>
<field type="text-single" label="Family Name" var="last"/><field type="text-single" label="Nickname" var="nick»/>
<field type="text-single" label="Birthday" var="bday»/>
<field type="text-single" label="Country" var="ctry»/>
<field type="text-single" label="City" var="locality»/>
<field type="text-single" label="Email" var="email»/>
<field type="text-single" label="Organization Name" var="orgname"/><field type="text-single" label="Organization Unit" var="orgunit»/>
</reported>
<item>
<field var="jid»>
<value>admin#company.com</value>
</field>
<field var="fn"><value/></field>
<field var="last"><value/></field>
<field var="first"><value/></field>
<field var="middle"><value/></field>
<field var="nick"><value/></field>
<field var="bday"><value/></field>
<field var="ctry"><value/></field>
<field var="locality"><value/></field>
<field var="email"><value/></field>
<field var="orgname"><value/></field>
<field var="orgunit"><value/></field></item>
</x>
</query>
</iq>
If there is no matches,you will just receive <reported> element with lots of fields. You may want to have look at this as well.
This search service doesn't support "plain" XEP-0055 search fields, but requires you to submit the x:data form returned in the response to the "get" request; see XEP-0004.
You can tell this by the fact that the result doesn't contain any suggested search fields as children of the query element (see example 2 of XEP-0055), and also the <instructions/> element says so. This means that you need to look at the <x xmlns="jabber:x:data" type="form"> element and submit it.
Thus, you need to send something like:
<iq type='set'
from='juliet#capulet.com/balcony'
to='characters.shakespeare.lit'
id='search4'
xml:lang='en'>
<query xmlns='jabber:iq:search'>
<x xmlns='jabber:x:data' type='submit'>
<field var='user'>
<value>admin</value>
</field>
</x>
</query>
</iq>
(This is example 8 from XEP-0055, modified to search for the user with username "admin".)

TFS2013 Requiring Comments on transitions to certain states

I'm creating a TFS 2013 Kanban board. I want to require an additional comment when the user switches the State to "Blocked From Progress"
Based on this post (http://social.msdn.microsoft.com/Forums/vstudio/en-US/9b672f4c-3054-481a-856d-4da650f25f74/how-to-require-comments-during-state-transition?forum=tfsprocess) I can require comments on all state changes. How do I limit it to just a transition to the "Blocked From Progress" State? Here's a section of code from my exported User Story xml file:
<FIELD name="HistoryHelper" refname="Demo.HistoryHelper" type="String">
<WHENNOT field="System.State" value="Blocked From Progress">
<COPY from="value" value="1" />
</WHENNOT>
<WHEN field="System.History" value="">
<COPY from="value" value="0" />
</WHEN>
<WHENNOT field="System.History" value="">
<COPY from="value" value="1" />
</WHENNOT>
<WHENCHANGED field="System.State">
<PROHIBITEDVALUES>
<LISTITEM value="0" />
</PROHIBITEDVALUES>
</WHENCHANGED>
</FIELD>
This is almost exactly the code from the above link, but I've added a check for the value of the State. Those lines don't seem to change the behavior at all. I've tried them at different places in the XML to no avail. Also, I've tried nesting a inside a and got errors. I don't know if there's a way to do an AND inside a WHEN.
EDIT
In addition to the accepted answer, I updated the new Field definition to be as follows:
<FIELD name="Blocked Reason" refname="CustomerProjects.BlockedReason" type="HTML" >
<WHENNOT field="System.State" value="Blocked From Progress">
<COPY from="value" value="" />
<READONLY />
</WHENNOT>
</FIELD>
I think a good solution for this would be to create a new field called "Blocked Reason" and then make it required on transitions into the "Blocked From Progress" state. You'd implement this like:
<Fields>
...
<FIELD name="Blocked Reason" refname="<company>.BlockedReason" type="HTML" />
...
</FIELDS>
<WORKFLOW>
...
<TRANSITIONS>
...
<TRANSITION from="<somestate>" to="Blocked From Progress">
...
<FIELDS>
<FIELD refname="<company>.BlockedReason">
<REQUIRED />
</FIELD>
</FIELDS>
</TRANSITION>
...
</TRANSITIONS>
...
</WORKFLOW>
You'd need to set that for each possible transition into the "Blocked From Progress" state. If you wanted you could also remove the text from the field using the tag on transitions out of the "Blocked From Progress" state.

how to achieve {0} in struts2 Field validation message

How to achieve parameterized message in struts2.
in actioname-validation.xml i have
<field name="family.familyName">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message key="common.required">
<argo key="common.family" />
</message>
</field-validator>
</field>
resource file i have,
common.required = {0} is required.
common.family = Family
some thing like this i tried. how to achive this?
This article explains how to do what you want. The gist of it is that you'd define your validation rule as follows:
<field name="family.familyName">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message key="common.required"/>
</field-validator>
</field>
And then in your .properties file, you'd have the following:
common.required = ${getText(fieldName)} is required.
family.familyName = Family
It gives me, what i expected
<field name="family.familyName">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message>
${getText("requiredstring", {getText("common.family")})}
</message>
</field-validator>
</field>
Application Resources,
requiredstring = {0} is required.
common.family = Family
It might be also resolved as follows
<field name="family.familyName">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message key="common.required">
<param name="1">getText('common.family')</param>
</message>
</field-validator>
</field>

Resources