I have a data in my database, which contains number and text both like [ 4,First Appeal ].Now fetch the data and want to show only the TEXT not the NUMBER part.How can I do
<tr>
<td><strong>Case type :</strong>{{ $case_details->case_type }}</td>
</tr>
Thanks in advance....
You can use explode on a string if it is always going to be comma separated. I would probably add some checking as the [0] could fail if there is no comma in the data. Secondly, I would suggest you revaluate how you are storing your data as it seems like this structure is not very efficient for multiple reasons. One suggestion would be be to only refer type to a number which has a config on the server which has the corresponding First Appeal or maybe a separate table of types with a foreign key to the types on case_details.
<tr>
<td><strong>Case type :</strong>{{ explode(",", $case_details->case_type)[0] }}</td>
</tr>
Related
For an example
<tr><th>sample1</th><th>sample2</th></tr><tr<td>data1</td><td>data2</td></tr>
In this above table we have no any attribute values. But they only have TagName. From that how we can find the unique xpath for all of them.I try using xpath like
//tr[not(#class) and not (#id)]
But by using it they can fetch all tr .so from that how we can find the unique xpath. Please can anybody know the answer update immediately with some demo...
Attribute values are handy but not required to select data in XPath.
For example, for your XML, formatted for legibility and fixed to be well-formed,
<table>
<tr>
<th>sample1</th>
<th>sample2</th>
</tr>
<tr>
<td>data1</td>
<td>data2</td>
</tr>
</table>
each of the following XPath expressions,
via position: /table/tr[2]/td[2]
via content: //td[.='data2']
via adjacency: //td[.='data1']/following-sibling::td[1]
via heading: //tr[2]/td[count(../../tr/th[.='sample2']/preceding-sibling::th)+1]
would select
<td>data2</td>
without relying upon attribute values.
See also
How to select table entry via XPath
I have an XML file containing Client id and addresses which I need to load into relational tables in Oracle database.
<Clients>
<Client id="100">
<name>ABC Corportation</name>
<Address>
<Addr1>1 Pine Street</Addr1>
<City>Chennai</City>
<State>Tamil Nadu</State>
<Country>India</Country>
<Postalcode>6000000</Postalcode>
</Address>
<Address>
<Addr1>1 Apple Street</Addr1>
<City>Coimbatore</City>
<State>Tamil Nadu</State>
<Country>India</Country>
<Postalcode>6000101</Postalcode>
</Address>
</Client>
<Client id="101">
....
....
</Client>
I have 2 relational tables defined as below-
Client
CLIENT_ID (Unique Key)
CLIENT_NAME
Client_Location
CLIENT_ID
ADDR1
CITY
STATE
COUNTRY
POSTAL_CODE
Updates to client address at source will sent in the XML file everyday. The ETL designed in a way that it requires a unique key on the table based on which it will identify the change coming in the XML as INSERT or UPDATE and accordingly sync the table to the XML. Identifying DELETEs is not really necessary.
Question: What should be defined as the unique key for Client_Location to process incremental changes coming everyday in the XML file? There is no identifier for address in the XML file. I was thinking about creating an additional hashing column (using ORA_HASH function) based on the 3 columns (STATE, COUNTRY, POSTAL_CODE). The unique key for the table would (CLIENT_ID, <>) which the ETL will use.. The idea is that it is not common for STATE/COUNTRY/POSTAL_CODE to change in an address. Ofcourse, this is a big assumption which I'm making. I would like to implement the below-
1) If there is any small change to ADDR1, I want the ETL to pick it up as a "valid" update at source and sync it to the table.
2) If there is a small change in the STATE/COUNTRY/POSTAL_CODE (eg: typo correction or case change like India to INDIA), then I don't want this to picked as a change because it would lead to INSERT (hashing value would change which is part of the unique key) and in turn duplicate rows in the table.
Does the idea of using a hashing column to define uniqueness make sense? Is there a better way to deal with this?
Is there a way to tweak ORA_HASH to produce results expected in #2 above?
If the client can have only one location reuse CLIENT_ID as primary key.
If there are more locations posible add SEQUENCEkey (sequence number 1..N) to the CLIENT_ID as a PK.
The simplest possibility to distinct and identify the locations is to use the feature of XML that the order of elements is well defined and has meaning. So the first ADDRESS element (pine street) becomes sequence 1, the second 2 and so on.
Please check the FOR ORDINALITY clause on XML table how to get this identification while parsing the XML.
You may also add TIMESTAMP (as a simple attribute - not a key) to keep the timestamp of the change and a STATUS column to identify deleted locations.
HASH may be usefull to quickly test a change if you have tons of columns, but for 5 columns it is probably an overkill (as you may simple compare the column values). I'd not recommend to used HASH as part of a key as it has no advantage to the proposed solution.
I am trying to extract the concatenated cells from a HTML table for each row using XPath. For example, if I have a table like
<table>
<tr><th>FirstName</th><th>LastName</th><th>Title</th></tr>
<tr><td>First1</td><td>Last1</td><td>Title1</td></tr>
<tr><td>First2</td><td>Last2</td><td>Title2</td></tr>
<tr><td>First3</td><td>Last3</td><td>Title3</td></tr>
</table>
I want to extract this data so that I get the full name of the person in each row
First1 Last1
First2 Last2
First3 Last3
I can get each column separately and then merge them in my code later, but prefer to get this done in a single XPath query. I have tried to use concat, but can't figure out where to use the concat.
Thanks in advance.
The concatenation you tried only concats the xpath, not the nodes. If you want to select more than one nodes, you should use | between them.
//tr//td[1] | //tr//td[2]
I have a Table full of players. Each of these players can have a list of Items that they own. What I need to do is store that list of items for each player. Each item has an ID which is unique.
What I want to do is store an array of these items as a field in the Player Table. Does anyone know how this could be accomplished?
You can either go database route and create table of "ItemId to PlayerId" and query all items for given player by ID.
Or you can serialize data in XML/byte array using default .Net serialization and than dump it in BLOB field of "playerId to PlayerBLOB" table (XML/text can also be stored as text field - will be more readable).
You can store it as a delimited text. BUT! store it as xml instead, this will allow you to store complex weapon list and configuration in a column.
I am trying to locate the first <th> element under a <table> element. The table element is tagged with a particular id, and is locatable when I only look as far as that tag.
But when I try to go a little further down and search using the XPath below, it returns a null element. The '/th[0]' is to say: return the first <th> element, under the element that is tagged with the particular id.
In the example, the id value is populated prior to the search:
"//*[#id='{0}']/th[0]"
XPath indexes are 1-based. Try: //*[#id='{0}']/th[1]
This trips me up all the time as well; too much time spent with 0-based indexing in C, C++, etc.