How to read the attribute value which is within CDATA from XML in Talend - xml-parsing

I am trying to read attribute value which is within a CDATA from XML in Talend. I am getting the value along with CDATA and not the value alone.
My XML format is :
<root>
<node attribute="![CDATA[value]]" />
</root>
In Xpath if i give attribute it is retrieving the value as ![CDATA[value]]. I want to get only "value". Is it possible to get the value inside the CDATA?

tMap or tJavaFlex set output value as:
row1.value.replaceAll("!\\[CDATA\\[","").replaceAll("\\]\\]","")
row1.value - change for You real name

Related

jmeter extract multiple array from xml

HTTP GET, retrive values from an xml
and than I need to call a PUT many times as the number of element with some values I got from the first GET.
I have an xml for example
<root>
<element>
<valId>1111</valId>
<valName>Name</valName>
</element>
<element>
<valId>1111</valId>
<valName>Name</valName>
</element>
....
</root>
So I have:
HTTP GET: retrive an xml
xpath extractor 1 for valsId
xpath extractor 2 for valsName
Now I have two array with multiple values in valId and valName, I can access to them with valsId_1, valsId_2, etc
Then I have a foreach controller in input I have valsId and output the current value myId.
as child of foreach controller I have my http PUT where I use myId but I don't know how to get the current value of valsName.
In my opinion for this kind of problem there two way:
1 extract the values in array, as I did
2 extract a part of xml and than process it everytime in a for
I hope you understand what I meant with my problem.
Any suggestions are welcome
For handling second variable "valsName" just place below code
${__BeanShell(vars.get("valsName_"+${__counter(TRUE,page)}))}
at the position of Name
<valName>Name</valName>
it'll resolve your problem.

TBXML doesn't parse tag with special character as value

I'm trying to parse an XML using TBXML and everything is going fine except for tags which contain special characters in their value.
For example, consider the XML element
<tag> sources/data </tag>
I'm trying to get the text sources/data from this tag. I'm using [TBXML textForElement:element] to achieve this. But it always returns an empty string.
The same code fails for another tag which is defined as :
<tag> array[i] </tag>.
But it works fine for normal text values like
<tag>name</tag>.
Can anyone help me out here ?
Quote: "Because XML syntax uses some characters for tags and attributes it is not possible to directly use those characters inside XML tags or attribute values."
http://www.dvteclipse.com/documentation/svlinter/How_to_use_special_characters_in_XML.3F.html
As I know this kind of data must be in placed CDATA.

IOS XML Parsing without attribute dict object for key?

I have an XML file which looks like this
<data>
<value>33</value>
</data>
Im trying to parse it but Im not sure how because every single tutorial on the web I have seen so far tells you how to do it with an XML element which looks like this:
<value id="somestupididhere"></value>
I want to do it without the "id=" bit. How do I allocate the value of a tag without having to add an id to it?

Struts property file value not printing properly

Hi i am using struts2 and hibernate in my project. When i am trying to print messages from property file the value is not printing instead its key is displaying
I have set salesMan.login.ErrorMessage=Invalid Username or Password in my mydrdirect.prperties file and also i have set <constant name="struts.custom.i18n.resources" value="myDrDirect" />. But when i call the getText function from action file the value print in the browser is salesMan.login.ErrorMessage. Anybody have idea about it?
Case 1: If the key you are using to get the value will not match with the key you provided in the property file, then it will display the "key" in the browser.
Case 2: mydrdirect.prperties
is this correct file name?

BizTalk 2006 R2 mapping problem

I have this data (all the elements are optional):
<data>
<optionalElement1>...</optionalElement1>
<optionalElement2>...</optionalElement2>
<optionalElement3>...</optionalElement3>
</data>
I need to map this to another schema (all the elements are required):
<request>
<Element1>...</Element1>
<Element2>...</Element2>
<Element3>...</Element3>
</request>
Since the elements in the original request are optional, the mapping will
only generate the corresponding elements for the originally included
elements. But the validation of the request will fail.
Example:
<data>
<optionalElement3>
<value1>1</value1>
<value2>2</value2>
</optionalElement3>
</data>
will be mapped to
<request>
<Element3>
<subelement1>1</subelement1>
<subelement2>2</subelement2>
</Element3>
</request>
And the validation will fail because i'm missing Element1 and Element2. The
response should be (I think):
<request>
<Element1 xsi:nil="true" />
<Element2 xsi:nil="true" />
<Element3>
<subelement1>1</subelement1>
<subelement2>2<subelement2>
</Element3>
</request>
How can I do this in the mapping? How can I ensure that the element is
created in the output message?
And, by the way, if a subelement is not present (let's say
"data/optionalElement1/value1" how can I make sure that the destination
subelement "request/Element1/subelement1" is created?
Make it very simple. Use the xlst file for mapping.
Using simple if condition you can check for value exist for opetion element or not, if value exist then map that else map the null (Empty) value. So the complex element will get generated even if there is no value for optional element.
Hope it will solve your problem.
You can do all this in the mapper. I haven't been into Biztalk for a while and I don't have it near me, but I know there are functiods in the mapper that lets you check for the existence of the fields you need. Depending on the existence of these field, you can specify what the appropriate action for the mapper is.
You force the creation of fields by giving them default values in the target schema. This can also be done using the mapper, via the properties window.
Jose,
You'll want to look at the table looping functoid. Here's a post about it.
http://geekswithblogs.net/Chilberto/archive/2008/04/16/121274.aspx
Using this functoid with the table extraction should give you your solution. Also here's a good series on understadning the mapper.
http://www.bizbert.com/bizbert/2008/02/07/Understanding+The+BizTalk+Mapper+Part+1+Introduction.aspx
-Bryan

Resources