Hy all,
I want to create a feed that matches GMC specifications.
The feed i created is:
https://www.kitisimo.ro/feed/feed-google-local-inventory.xml
` <item>
<g:id>c1</g:id>
<g:quantity>1</g:quantity>
<g:price>75</g:price>
<g:store_code>12169613935259656004</g:store_code>
</item> `
As you can see there is no
`[CDATA]`
in the id string
However, when processed by GMC the feed looks like this:
` <item>
<g:id>
<![CDATA[ c1 ]]>
</g:id>
<g:quantity>1</g:quantity>
<g:price>75</g:price>
<g:store_code>12169613935259656004</g:store_code>
<g:sale_price>0</g:sale_price>
</item> `
and i have the "Invalid or missing required attribute: store code" error.
I asked google support and this is the reply:
"After checking the feed, I was able to verify that the store code is available. Checking the item ID: c3 which has a store code: 12169613935259656004 from the feed, our final attribute was not able to capture the store code. After further investigation, I noticed that your Item ID from your xml feed <g:id><![CDATA[ c3 ]]></g:id>
type here
. Based on our formatting guide for item ID, it should be <g:id>c3</g:id> "
Does anyone has an idea on how to proceed to prevent
`[CDATA]`
from appearing in GMC feed?
I tried to create a feed according to GMC specs.
I am expecting some help regarding the matter.
Related
How do we get the internalId of contactrole in netsuite. I am basically trying to add a contactrole as part of contact attach to a customer record. I need to fill in the internalId attribute for contactRole below to add the proper contactRole. But I am not able to search for the internalIds of existing contactRole from the netsuite UI. Any help appreciated. Snippet Below.
<soapenv:Body xmlns:sales="urn:sales_2018_2.transactions.webservices.netsuite.com">
<urn:attach>
<urn:attachReference xsi:type="core:AttachContactReference">
<core:attachTo internalId="1298" xsi:type="core:RecordRef" type="customer" />
<contact internalId="1307" xsi:type="core:RecordRef"/>
<contactRole xsi:type="core:RecordRef"/>
</urn:attachReference>
</urn:attach>
</soapenv:Body>
here is where it can be found on netsuite UI. Setup-sales-CRM Lists
I'm trying to use the Google Analytics measurement protocol to send a hit to GA when someone opens an email from Mailchimp. The documentation I'm following is here: https://www.lunametrics.com/blog/2013/06/17/email-tracking-google-analytics/
I'd like to use Mailchimp merge tags to insert dynamic values for some of the parameters. For example:
client id --> be cid=*|UNIQID|*
event label --> el=*|MC:SUBJECT|*
An example of pixel code placed at the end of an email:
img
src="http://www.google-analytics.com/collect?v=1&tid=UA-XXXX-Y&cid=*|UNIQID|*&t=event&ec=Email&ea=open&el=*|MC:SUBJECT|*&cm=email&cs=*|LIST:NAME|*&cn=*|CAMPAIGN_UID|*&cc=teaser2&cm1=1"
In GA, none of the merge tag values are showing up. The client ID is "*|UNIQID|*" instead of a dynamically inserted value and the event label is "(not set)".
I am trying to understand how nodes work in order to get their values.
The sample XMl code is
<MediaContainer size="1">
<Video addedAt="1463113546">
<User id="365343" thumb="something" title="UserA"/>
</Video>
</MediaContainer>
I know below will get the User ID using powershell, however trying to also get the title value which contains the username.
$xml.MediaContainer.Video.User.id
When looping through not every line that has a User id will have a thumb value. In other words it can also say
<User id="343" title="UserB"/>
First ,
[System.Xml.XmlDocument]$xml = new-object System.Xml.XmlDocument
$xml.load(<file_path>)
Then,
Get User ID : $xml.MediaContainer.Video.User.id
Get title : $xml.MediaContainer.Video.User.title
I'm new to REST but I've built a simple web service and I'm having trouble finding a simple explaination of what URL format would be correct.
The service allows to create an invoice and push it through a series of simple approval phases.
(1) Read all invoices in an XML format:
GET: http://localhost/webapp/ws/invoices
(2) Read one invoice in an XML format (ex. invoice id = 555):
GET: http://localhost/webapp/ws/invoices/555
(3) Submit a new invoice:
POST: http://localhost/webapp/ws/invoices
With the invoice attributes ("userid", "totalprice", etc) are included like the POST parameters of a simple HTML form.
(4) Approve an invoice:
POST: http://localhost/webapp/ws/invoices/action
With the action attributes (ex. "userid=123", invoiceid=567, "action=APPROVE" or "REJECT", etc) are included like the POST parameters of a simple HTML form.
It works fine, but is that even close to what a RESTful web service is supposed to look like?
Any advice is greatly appreciated, thanks.
Rob
The URLs don't make an API RESTful or not. It is more important to clearly represent your resources and their state transitions (through links and forms) and avoiding out-of-band information that couples clients to your implementation. A RESTful Hypermedia API in Three Easy Steps covers this concept nicely.
1) Create a root resource that provides a well know starting point for all clients and allows them to discover the services available (this can be the same URL used by Browers. Use the Accept header to determine if HTML or your APIs media-type should be returned).
GET: http://localhost/webapp
<webapp href="/webapp">
<invoices href="/webapp/invoices"/>
... any other services ...
</webapp>
2) Create a collection resource for you invoices
GET: http://localhost/webapp/invoices
<invoices href="/webapp/invoices">
<invoice href="/webapp/invoices/555"/>
<invoice href="/webapp/invoices/554"/>
<invoice href="/webapp/invoices/553"/>
<invoice href="/webapp/invoices/552"/>
...
<search href="/webapp/invoices/" method="get">
<query type="xpath" cardinality="required"/>
</search>
<next href="/webapp/invoices?page=2" method="get"/>
<create-draft href="/webapp/invoices" method="post">
<total-price type="decimal" cardinality="optional"/>
... user should be picked up automatically based on the authorised user posting the form ...
... add other optional and required parameters here. ...
</create-draft>
</invoices>
This is a paginated collection, with the next element telling the client how to get the next page. If there weren't enough invoices (e.g., 5 invoices and each page can contain 10) then the next element would not be show. Similarly if the requester is no authorised to create invoices then the create-draft form would not be included.
Getting the next page would look something like:
GET: http://localhost/webapp/invoices?page=2
<invoices href="/webapp/invoices">
<invoice href="/webapp/invoices/545"/>
<invoice href="/webapp/invoices/544"/>
<invoice href="/webapp/invoices/543"/>
<invoice href="/webapp/invoices/542"/>
...
<search href="/webapp/invoices/" method="get">
<query type="xpath" cardinality="required"/>
</search>
<next href="/webapp/invoices?page=3" method="get"/>
<prev href="/webapp/invoices" method="get"/>
<create-draft href="/webapp/invoices" method="post">
<total-price type="xs:decimal" cardinality="optional"/>
... user should be picked up automatically based on the authorised user posting the form ...
... add other optional and required parameters here. ...
</create-draft>
</invoices>
3) Create an item resource for your invoices
GET: http://localhost/webapp/invoices/555
<invoice href="/webapp/invoice/555">
... details go here ...
<reject href="/webapp/invoices/555" method="delete">
<reason type="xs:string" cardinality="required"/>
</reject>
<approve href="/webapp/invoices/555" method="put">
... add approval parameters here ...
</approve>
</invoices>
Similarly, if the user is not authorised to reject or approve invoices then those elements should not be displayed. Same goes if the invoice has already been approved (in which case maybe there is a cancel form).
IMHO for the approval process I would do:
(4) Approve an invoice:
PUT: http://localhost/webapp/ws/invoices/555
As you are going to modify an existing resource, identified by the ID (555), so you only need to pass the attributes that will change.
i want to parse the xml File. xml File structure is following
<?xml version="1.0" encoding="utf-8"?>
<Level>
<p id='327'>
<Item>
<Id>5877</Id>
<Type>0</Type>
<Icon>---</Icon>
<Title>Btn1Item1</Title>
</Item>
<Item>
<Id>5925</Id>
<Type>0</Type>
<Icon>---</Icon>
<Title>Btn1Item4</Title>
</Item>
</p>
<p id='328'>
<Item>
<Id>5878</Id>
<Type>0</Type>
<Icon>---</Icon>
<Title>Btn2Item1</Title>
</Item>
<Item>
<Id>5926</Id>
<Type>0</Type>
<Icon>---</Icon>
<Title>Btn2Item4</Title>
</Item>
</p>
</Level>
in above code there are only 2 tag for <p>. but in actual there are multiple tag. i want to search the specific tag for which attribute id have some specific value (say 327).
so one way is that i parse the XML file from start to get the desired result. whether there are any other method from which i can direct locate the desired tag. for example if i want to search the <p> tag in above XML for attribute id =328, then it does not parse the id=327 and direct return only those item which are related to id=328
Please suggest
Depends how you define "parse".
A "quick & dirty" (and potentially buggy) way would be to find the fragment using a regex search (or a custom parser) first, then feed the fragment to a true XML parser. I don't know of anything that would do this for you, you'd have to roll it yourself. I would suggest that it's not the way to go.
The next level is to feed it through a SAX-like parser (which NSXMLParser is a form of).
In your handler for the <p> element, check the id attribute and if it matches your value (or values), set a flag to indicate if child elements should be interpreted.
In your child element handlers, just check that flag first (in a raw NSXMLParser handler all elements would go to the same method, of course).
So it's true that NSXMLParser would be parsing the whole document - but just to do the minimal work to establish the correct XML parser context. The real work of handling the elements would be deferred until the value is met. I don't see any way around that without something hacky like the regex suggestion.
If this is too much overhead I'd reconsider whether XML is the right serialization format for you (assuming you have any control over that)?
If you do stick with NSXMLParser, my blog article here might help to at least make the experience nicer.
The libxml2 library can receive XPath queries with the following extensions. With these extensions you might issue the XPath query /p[#id = "328"] to retrieve that specific node's children.