I am new to blackberry 10 platform I am stuck with XML CDATA parsing . I am currently using QXMLSTREAMREADER and it is efficient to get the attributes but not getting CDATA. The Xml I used is
as follows
<message_list>
<message title = "title1" date = "21-08-2012 10:20">
[CDATA[ Sample data here ]]
</message>
<message title = "title2" date = "21-08-2012 10:20">
[CDATA[Sample data here]]
</message>
</message_list>
Use custom class extend from QXmlDefaultHandler and can parse CDATA there
Related
I am using spark 2.3.2 with python 3.7 to parse xml.
In an xml file (sample), I have appended 2 xmls.
When I parse it with:
os.environ['PYSPARK_SUBMIT_ARGS'] = '--packages com.databricks:spark-xml_2.11:0.7.0 pyspark-shell'
conf = pyspark.SparkConf()
sc = SparkSession.builder.config(conf=conf).getOrCreate()
spark = SQLContext(sc)
dfSample = (spark.read.format("xml").option("rowTag", "xocs:doc")
.load(r"sample.xml"))
I see 2 xmls' data:
However, what I need is to extract the info under "ref-info" tag (along with their corresponding key eids), so my code is:
(dfSample.
withColumn("metaExp", F.explode(F.array("xocs:meta"))).
withColumn("eid", F.col("metaExp.xocs:eid")).
select("eid","xocs:item").
withColumn("xocs:itemExp", F.explode(F.array("xocs:item"))).
withColumn("item", F.col("xocs:itemExp.item")).
withColumn("itemExp", F.explode(F.array("item"))).
withColumn("bibrecord", F.col("item.bibrecord")).
withColumn("bibrecordExp", F.explode(F.array("bibrecord"))).
withColumn("tail", F.col("bibrecord.tail")).
withColumn("tailExp", F.explode(F.array("tail"))).
withColumn("bibliography", F.col("tail.bibliography")).
withColumn("bibliographyExp", F.explode(F.array("bibliography"))).
withColumn("reference", F.col("bibliography.reference")).
withColumn("referenceExp", F.explode(F.array("reference"))).
withColumn("ref-infoExp", F.explode(F.col("reference.ref-info"))).
withColumn("authors", F.explode(F.col("ref-infoExp.ref-authors.author"))).
withColumn("py", (F.col("ref-infoExp.ref-publicationyear._first"))).
withColumn("so", (F.col("ref-infoExp.ref-sourcetitle"))).
withColumn("ti", (F.col("ref-infoExp.ref-title"))).
drop("xocs:item", "xocs:itemExp", "item", "itemExp", "bibrecord", "bibrecordExp", "tail", "tailExp", "bibliography",
"bibliographyExp", "reference", "referenceExp").show())
This extracts the info only from the xml with eid = 85082880163
When I delete this one and only kept the one with eid = 85082880158, it works.
My file is an xml file containing those 2 lines in the link. I have also tried to merge those 2 into one xml but could not manage.
What is wrong with my data/approach? (My ultimate plan is to create such a file containing thousands of different xmls to be parsed)
Your trouble lies in this piece of XML:
<xocs:item>
<item>
<bibrecord>
<head>
<abstracts>
<abstract original="y" xml:lang="eng">
<ce:para>
Apple is often affected by [...] intercellular CO <inf>2</inf> concentration [...]
^^^^^^^^^^^^
While it is correct XML (mixed content), this embedded tag <inf>2</inf> seems to be breaking spark-xml parser. If you remove it (or convert to corresponding HTML entities) you will get correct results.
I have:
Raw xml filled by a select query.This xml transformed into a HL7
message
One of the tags of this xml represents a clob column from a table in
the database
I mapped this data (from edit transformer section) as a variable.
Now I am trying to convert this variable into a base64 string then
replace it in my transformed hl7 message.
5.I tried this conversion on a destination channel which is a javascript writer.
I read and tried several conversion methods like
Packages.org.apache.commons.codec.binary.Base64.encodeBase64String();
I have got only error messages like :
EvaluatorException: Can't find method org.apache.commons.codec.binary.Base64.encodeBase64String(java.lang.String);
Code piece:
var ads=$('V_REPORT_CLOB');
var encoded = Packages.org.apache.commons.codec.binary.Base64.encodeBase64String(ads.toString());
It is pretty clear that I am a newbie on that.How can I manage to do this conversion ?
Here is what I use for Base64 encoding a string with your var substituted.
//Encode Base 64//
var ads = $('V_REPORT_CLOB');
var adsLength = ads.length;
var base64Bytes = [];
for(i = 0; i < adsLength;i++){
base64Bytes.push(ads.charCodeAt(i));
}
var encodedData = FileUtil.encode(base64Bytes);
I'm trying to retrieve HTML Class Names from a string variable created by responseText. I need to accomplish this using VBscript. Here is a sample of current code:
set http = createobject("Microsoft.XmlHttp")
http.open "GET","http://www.xxxxxxxxxxx.com/xxx-xxx?xxxxNumber=xxxxx",false
http.send ""
dim html : set html = CreateObject("HTMLFILE")
html.write http.responseText
dim trackdate : trackdate = html.getElementByClassName("tracking-history-date").[0].value
wscript.echo trackdate
I'm receiving the following error: Object doesn't support this property or mehtod: 'getElementByClassName'
I've run into this before. Although documented, the getElementsByClassName() method doesn't seem to actually be supported. Use something like this to work around the issue:
For Each el In html.getElementsByTagName("...")
If el.ClassName = "tracking-history-date" Then
Set trackdate = el
Exit For
End If
Next
I have:
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$this->render("voucher-list");
The problem is, when I execute:
$this->render("voucher-list");
It actually prints the information to screen. I want to return the data as an HTML string. This DOES NOT work:
$htmlcontent = $this->render("voucher-list");
How would I go about returning this information as a string?
If you want to send the data into JSON format then you need to make the array of data and use the following code to send the data:
$data = array(3,4,'test', 'my-name' => 3,4); //suppose this is your data
$this->_helper->viewRenderer->setNoRender(true);
$this->view->layout()->disableLayout();
echo Zend_Json::encode($data);
And you will get the data in JSON format.
See this: Zend Framework JSON Output
Im using Open XML SDK to read and write information to custom xml parts in a Word document.
Im serializing a xml structure into a class , modifying the data and serializing it back into the document.
Example code
DocumentFormat.OpenXml.Packaging.CustomXmlPart myPart = GetCustomXmlPart(mainPart, AITNamespaces.SiteDataNameSpace);
StreamReader myStrR = new System.IO.StreamReader(myPart.GetStream());
string myXML = myStrR.ReadToEnd();
sitedata = ObjectXMLSerializer<WDSiteData>.LoadString(myXML);
Site selSite = _applicationService.GetApplicationData().Sites.Find(item => item.Id == siteId);
sitedata.SiteId= selSite.Id;
sitedata.SiteName = "ööööaaaaaåååå"; // selSite.SiteName;
myXML = ObjectXMLSerializer<WDSiteData>.GetXMLString(sitedata);
myPart = GetCustomXmlPart(wordProcDocument.MainDocumentPart, AITNamespaces.SiteDataNameSpace);
using (StreamWriter sw = new StreamWriter(myPart.GetStream(FileMode.Create)))
{
sw.Write(myXML);
}
My problem is that the national characters become encoded and the text "ööööaaaaaåååå" is displayed in the word document as "????????aaaaa????????"
The actual encoding is done
myXML = ObjectXMLSerializer<WDSiteData>.GetXMLString(sitedata);
Anyone has a clue on how to go about handling national characters this way.
For whom it concerns , my trouble was that in my serializer the encoding was fixed
return ASCIIEncoding.ASCII.GetString(memStream.ToArray());
When i changed to
return ASCIIEncoding.UTF8.GetString(memStream.ToArray());
all is well.