Xml parsing problem - iphone

I have an xml like this
<?xml version="1.0" encoding="UTF-8" ?>
<product>
<productname> ----->Dynamic node
</title>
</price>
</desc>
</productname>
<productname> ---->Dynamic node
</title>
</price>
</desc>
</productname>
</product>
productname node is dynamic depends on our request.
how to get the name of the element (productname) and the values of an element.

I use touch xml by Jonathan Wight.

Related

How to send complex message headers using citrus test frame work

As of now according to the information mentioned in the citrus documentation we can send header using element tag .I have a header like this
<usr><scenarioname>xx</scenarionname><instanceID>xx<<instanceID><usr>
I am sending the above header using follwing send action
<send endpoint="helloServiceEndpoint">
<message>
<payload>
<TestMessage>
<Text>Hello!</Text>
</TestMessage>
</payload>
</message>
<header>
<element name="scenarioname" value="xx"/>
<element name="instanceID" value="xx"/>
</header>
</receive>
But I want to post a complex header which not just like name value pairs but the header contains nested xml elements. how can i achieve this using citrus
example of complex header
<usr>
<scenarioname>xx</scenarionname>
<instanceID>xx<<instanceID>
<parameters>
<basicauthentication>
<username>xxxxx</username>
<password>xxxx</password>
</basicauthentication>
.
.
.
.
.
</parameters>
</usr>
The element is for name-value pairs only. You need to use the data element in the header section in order to add a complex header fragment.
<send endpoint="helloServiceEndpoint">
<message>
<payload>
<TestMessage>
<Text>Hello!</Text>
</TestMessage>
</payload>
</message>
<header>
<data>
<![CDATA[
<usr>
<scenarioname>xx</scenarionname>
<instanceID>xx</instanceID>
</usr>
]]>
</data>
</header>
</send>

Use of topicmeta in topic body

I am starting to use DITA for writing product specifications. I use the "prodname" metadata to put the product number in the header. Now I am wondering how if at all I can use the same information in the body part of my document. Is there a DITA way to use this information for my purpose? Or is this not "proper" usage?
You can create a <keyword> element and reuse it via a key reference.
DITA Map
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">
<map>
<title><keyword keyref="product"/></title>
<keydef keys="product">
<topicmeta>
<keywords>
<keyword>my product</keyword>
</keywords>
</topicmeta>
</keydef>
<topicref href="topic.dita"/>
</map>
DITA Topic
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="topic">
<title>my topic</title>
<prolog>
<metadata>
<prodinfo>
<prodname>
<keyword keyref="product"/>
</prodname>
</prodinfo>
</metadata>
</prolog>
<body>
<p><keyword keyref="product"/></p>
</body>
</topic>

Remove Block Programmatically in Magento2

We are able to remove block in Magento1 with unsetBlock() method, but in Magento2 it is not working. So, please help how can remove block in Magento2 programmatically ?
Use unsetElement() method to remove block.
as like
$layout = $this->getLayout();
$block = $layout->getBlock('catalog.topnav'); // block name
$layout->unsetElement('catalog.topnav');
You need to try this way, for example, I am removing compare from the sidebar so I override default.xml to app/design/frontend/Your_Theme/theme_name/Magento_Catalog/layout
<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="catalog.compare.sidebar" remove="true"/>
</body>
To Remove particular block from page, Open your custom layout xml and place the below code under body Tag
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body><referenceBlock name="Your_Block" remove="true"/>
</body>
</page>
Change Your_Block this one to your block name need to be remove
Ideally there are different ways to do this. The best way of doing it is using a layout file.
1) If you have build a module you can create a layout which is an xml file in app/code/Namespace/Your_Module/view/frontend/layout/frontname_controllername_controlleraction.xml and add the below code
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<referenceBlock name="block_name" remove="true" />
</page>
2) If you have not created a custom module of your's you can simply write a custom xml in app/design/frontend/Custom_Theme/Theme_name/Module_Name/layout and add the below code.
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<referenceBlock name="block_name" remove="true" />
</page>

Google Merchant throws warning "Unrecognized attribute"

I'm facing an issue I can not explain :
When I'm uploading a feed to Google Merchant in an other language than English, the reports tells me there is many "Unrecognized attribute" that should be valid, like title, link, description, gtin, etc.
In fact, all attributes are considered warning from Google.
But the issue only occurs if it's not in english so my feed seems correct.
What is wrong? Do you have any ideas?
Thank for your help.
Here's a dump of my export (strimed to one product) :
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<title>Google Shopping export for PrestaShop</title>
<item>
<g:id xmlns:g="http://base.google.com/ns/1.0">12345</g:id>
<title>
<![CDATA[ Basic title ]]>
</title>
<link>
<![CDATA[
https://www.example.com/test
]]>
</link>
<description>
<![CDATA[
This is a basic product
]]>
</description>
<g:quantity xmlns:g="http://base.google.com/ns/1.0">39</g:quantity>
<g:availability xmlns:g="http://base.google.com/ns/1.0">
<![CDATA[ in stock ]]>
</g:availability>
<g:price xmlns:g="http://base.google.com/ns/1.0">8.54 EUR</g:price>
<g:product_type xmlns:g="http://base.google.com/ns/1.0">
<![CDATA[ Ofertas > Ofertas ]]>
</g:product_type>
<g:google_product_category xmlns:g="http://base.google.com/ns/1.0">
<![CDATA[
AlimentaciĆ³n, bebida y tabaco > Bebidas > Vino
]]>
</g:google_product_category>
<g:shipping_weight xmlns:g="http://base.google.com/ns/1.0">1.4 kg</g:shipping_weight>
<g:online_only xmlns:g="http://base.google.com/ns/1.0">n</g:online_only>
<g:condition xmlns:g="http://base.google.com/ns/1.0">new</g:condition>
<g:brand xmlns:g="http://base.google.com/ns/1.0">Angove Family Winemakers</g:brand>
<g:mpn xmlns:g="http://base.google.com/ns/1.0">23500023</g:mpn>
<g:gtin xmlns:g="http://base.google.com/ns/1.0"/>
<identifier_exists>FALSE</identifier_exists>
<g:image_link xmlns:g="http://base.google.com/ns/1.0">
<![CDATA[
http://example.com/test/images/1.jpg
]]>
</g:image_link>
<g:shipping xmlns:g="http://base.google.com/ns/1.0">
<g:country>ES</g:country>
<g:service>
<![CDATA[ ENVIALIA-72H ]]>
</g:service>
<g:price>24.2 EUR</g:price>
</g:shipping>
</item>
</channel>
</rss>
I presume you are uploading this as XML.
Are you encoding correctly your xml?
If you're submitting an XML file that uses either Latin-1 or UTF-16 encoding, please make sure you specify this information in your XML file. To do this, please change the first line of your data feed from to:
For Latin-1:
<?xml version="1.0" encoding="ISO-8859-1"?>
For UTF-16:
<?xml version="1.0" encoding="UTF-16"?>
I read this from here:
https://support.google.com/merchants/answer/160079
Also, have you tried to use a XML escape tool? Such as http://www.freeformatter.com/xml-escape.html
I hope this helps!
Have you tried changing the "feed type" to "product" instead of "online product inventory update"? There has been a change since 2015.
<identifier_exists>FALSE</identifier_exists>
should be
<g:identifier_exists>false</g:identifier_exists>
also you have excessive CDATA usage. I don't have any in my XML and it works jut fine. try to submit file without CDATA`s

XSL Transform - Remove Parent Node

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:enterprise.soap.sforce.com">
<soapenv:Body>
<upsertResponse>
<result>
<created>true</created>
<id>0011</id>
<success>true</success>
</result>
<result>
<created>false</created>
<id>0012</id>
<success>true</success>
</result>
</upsertResponse>
</soapenv:Body>
</soapenv:Envelope>
**How can I transform this to**
<upsertResponse>
<result>
<created>true</created>
<id>0011</id>
<success>true</success>
</result>
<result>
<created>false</created>
<id>0012</id>
<success>true</success>
</result>
</upsertResponse>
This is an example of XSL that takes the first child of first child of root and makes it root node of new XML:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:copy-of select="./*[1]/*[1]/*[1]" />
</xsl:template>
</xsl:stylesheet>
Please note that you can take only one node and not multiple nodes since placing few nodes as root of XML is not valid.
Use an <xsl:match> to select the <upsertResponse> element, then put an <xsl:copy> inside of it. That should do the trick. Sorry I don't have the exact syntax, but hopefully this points you in the right direction.