Below is my result from web service, how can I change the record name so that it's uniquely identified? e.g. Record1, Record2, Record3.
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<ArrayOfRecord xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
<Record> /*How to change this Record to Record1*/
<item>
Buffalo DriveStation Combo 3.5 inch External Hard Drive USB 2.0 1.5TB Quadra
</item>
<qty>1</qty>
<qtyapproved>1</qtyapproved>
<availability>0</availability>
<description>Returned</description>
<itemdescription>-</itemdescription>
<id>188</id>
</Record>
<Record>
<item>eSataII HDD Docking with 1TB 3.5 inch hard disk</item>
<qty>1</qty>
<qtyapproved>1</qtyapproved>
<availability>0</availability>
<description>Returned</description>
<itemdescription/>
<id>184</id>
</Record>
</ArrayOfRecord>
Instead of changing the record name include a unique column in the resultset being returned by the web service, you can use a sequence number if you do not have any unique column.
For example you can add itemId a new column in Record
<Record> /*How to change this Record to Record1*/
<itemId>1</itemId>
<item>
Buffalo DriveStation Combo 3.5 inch External Hard Drive USB 2.0 1.5TB Quadra
</item>
<qty>1</qty>
<qtyapproved>1</qtyapproved>
<availability>0</availability>
<description>Returned</description>
<itemdescription>-</itemdescription>
<id>188</id>
</Record>
Related
I have this template from a bank that is used to make payments on bank account transfers.
See xml below. I have included the sample data that has to be entered when sending the file to the bank.
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CstmrCdtTrfInitn>
<GrpHdr>
<MsgId>Cart Urgent28052018_57894</MsgId>
<CreDtTm>2018-06-29T11:52:23</CreDtTm>
<NbOfTxs>1</NbOfTxs>
<CtrlSum>667896.00</CtrlSum>
<InitgPty>
<Nm>CART LIMITED</Nm>
<Id>
<OrgId>
<Othr>
<Id>S001234/PJones</Id>
<SchmeNm>
<Cd>CUST</Cd>
</SchmeNm>
</Othr>
</OrgId>
</Id>
</InitgPty>
</GrpHdr>
<PmtInf>
<PmtInfId>Payment for addon development SAP B1</PmtInfId>
<PmtMtd>TRF</PmtMtd>
<BtchBookg>false</BtchBookg>
<NbOfTxs>1</NbOfTxs>
<CtrlSum>667896.00</CtrlSum>
<PmtTpInf>
<InstrPrty>HIGH</InstrPrty>
</PmtTpInf>
<ReqdExctnDt>2018-06-29</ReqdExctnDt>
<Dbtr>
<Nm>CART LIMITED</Nm>
</Dbtr>
<DbtrAcct>
<Id>
<Othr>
<Id>0112345110846</Id>
</Othr>
</Id>
<Ccy>KES</Ccy>
</DbtrAcct>
<DbtrAgt>
<FinInstnId>
<BIC>SBICKENX</BIC>
</FinInstnId>
</DbtrAgt>
<CdtTrfTxInf>
<PmtId>
<EndToEndId>156335578965</EndToEndId>
</PmtId>
<Amt>
<InstdAmt Ccy="KES">667896.00</InstdAmt>
</Amt>
<ChrgBr>DEBT</ChrgBr>
<CdtrAgt>
<FinInstnId>
<BIC>DTKEKENA</BIC>
<ClrSysMmbId>
<MmbId>63000</MmbId>
</ClrSysMmbId>
</FinInstnId>
</CdtrAgt>
<Cdtr>
<Nm>EOH SEAL LTD</Nm>
<PstlAdr>
<StrtNm>P.O. Box 10496</StrtNm>
<TwnNm>Nairobi</TwnNm>
<Ctry>KE</Ctry>
<AdrLine>P.O. Box 10496</AdrLine>
<AdrLine>00100 NAIROBI</AdrLine>
</PstlAdr>
</Cdtr>
<CdtrAcct>
<Id>
<Othr>
<Id>0112406001</Id>
</Othr>
</Id>
</CdtrAcct>
<RmtInf>
<Ustrd>Cart Urgent28052018_57894</Ustrd>
</RmtInf>
</CdtTrfTxInf>
</PmtInf>
</CstmrCdtTrfInitn>
</Document>
The file is quite long as has to be in the format given. The black letters represent the details to be passed to the xml. To test if I understood what data goes where I filled it manually and sent to bank for testing. That is all good now.
I have a SAP addon program that captures details from a form and generates a list. Each payment must follow this structure.
Looking at the below:
<Nm>CART LIMITED</Nm>
<Id>
<OrgId>
<Othr>
<Id>S001234/PJones</Id>
<SchmeNm>
<Cd>CUST</Cd>
</SchmeNm>
</Othr>
</OrgId>
</Id>
Is creating a class with all properties according to the template the best way to create the xml needed.
How do I stagger the
<Id>
<OrgId>
<Othr>
as in the case above?
Also the <CtrlSum>667896.00</CtrlSum> is found in the group header and payment info tags. How do I deal with this?
For what i see, the problem is you have a addon in SAP to specify multiple payments methods, but in the XML template given from the bank you don't the structure for multiple payments, so you need to get this information to know how can you work with it.
when you have this information you can use a better XML template with VS or another tool to generate the correct class to work with the XML
hi following XML is my input XML
<?xml version="1.0" encoding="utf-8"?>
<units xmlns="http://www.elsevier.com/xml/ani/ani" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ce="http://www.elsevier.com/xml/ani/common" xsi:schemaLocation="http://www.elsevier.com/xml/ani/ani http://www.elsevier.com/xml/ani/ani512-input-CAR.xsd">
<unit type="journal" xmlns="">
<unit-info>
<timestamp>2017-01-08T02:03:14Z</timestamp>
<order-id>12535892</order-id>
<parcel-id>none</parcel-id>
<unit-id>4756202</unit-id>
</unit-info>
<unit-content>
<bibrecord>
<item-info>
<status state="new" stage="S300" />
</item-info>
<head>
<citation-info>
<citation-type code="jo" />
<citation-language xmllang="ENG" />
<abstract-language xmllang="ENG" />
<author-keywords>
<author-keyword>Stroke</author-keyword>
<author-keyword> cerebral ischaemia</author-keyword>
<author-keyword> Neuro-protection</author-keyword>
<author-keyword> Neuro-protective agents</author-keyword>
</author-keywords>
</citation-info>
<citation-title xmllang="ENG" original="y">
<titletext>PATHOGENESIS AND NEURO-PROTECTIVE AGENTS OF STROKE</titletext>
</citation-title>
<abstracts>
<abstract>
<cepara>ABSTRACT: Stroke remains worlds second leading cause of mortality; and globally most frequent cause of long-lasting disabilities. The ischaemic pathophysiologic cascade leading to neuronal damage consists of peri-infarct depolarization, excitotoxicity, inflammation, oxidative stress, and apoptosis. Despite plethora of experimental evidences and advancement into the development of treatments, clinical treatment of acute stroke still remains challenging. Neuro-protective agents, as novel therapeutic strategy confer neuro-protection by targeting the pathophysiologic mechanism of stroke. The aim of this review is discussion of summary of the literature on stroke pathophysiology, current preclinical research findings of neuroprotective agents in stroke and possible factors that were responsible for the failure of these agents to translate in human stroke therapies.</cepara>
</abstract>
</abstracts>
<correspondence>
<person>
<ceinitials>M.</ceinitials>
<cesurname>Mubarak</cesurname>
</person>
<affiliation>
<organization> Bayero University Kano</organization>
<organization> Nigeria. Email: mubarakmahmad#yahoo.com</organization>
</affiliation>
</correspondence>
<root>
<author Seq="0">
<Inital>A.El</Inital>
<Surname>Khattabi</Surname>
<Givenname>Abdelkrim</Givenname>
</author>
</root>
</head>
</bibrecord>
</unit-content>
from this xml i need to delete root tag alone but i need all child element
<author Seq="0">
<Inital>A.El</Inital>
<Surname>Khattabi</Surname>
<Givenname>Abdelkrim</Givenname>
</author>
how to delete root tag alone. For this i followed following code
XDocument CarXML = new XDocument();
CarXML.Add(Root);
CarXML.Descendants("root").Remove();
CarXML.Save(#"CAR.XML");
But this code delete all xml tag. How to delete root element alone. i need child element
CarXML.ReplaceNodes(CarXML.Descendants("author").FirstOrDefault());
This replaces the whole content of the XML with the first descendant named author.
This is my QBXML request
<?xml version="1.0" ?>
<?qbxml version="6.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<InvoiceModRq requestID="1">
<InvoiceMod>
<TxnID>85-1442639879</TxnID>
<EditSequence>1442639879</EditSequence>
<CustomerRef>
<ListID>80000005-1442639850</ListID>
<FullName>Bruce Banner</FullName>
</CustomerRef>
<TxnDate>2015-09-19</TxnDate>
<RefNumber>5462</RefNumber>
<InvoiceLineMod>
<ItemRef>
<ListID>8000000A-1442469770</ListID>
<FullName>Item 1</FullName>
</ItemRef>
<Quantity>1</Quantity>
<Rate>1100.00</Rate>
</InvoiceLineMod>
</InvoiceMod>
</InvoiceModRq>
</QBXMLMsgsRq>
</QBXML>
I am getting an error
QuickBooks found an error when parsing the provided XML text stream.
please help
If you refer to the QuickBooks OSR:
https://developer-static.intuit.com/qbSDK-current/Common/newOSR/index.html
You'll notice that within the <InvoiceLineMod> element, this node is required:
<TxnLineID>
The OSR gives you a bit more information too:
TxnLineID
Identification number of the transaction line. (TxnLineID
is supported as of v2.0 of the SDK. With qbXML v1.0 and v1.1,
TxnLineID is always returned as zero.)
If you need to add a new transaction line in a transaction Mod
request, you can do so by setting the TxnLineID to -1.
So, you'll need to add in a <TxnLineID> node. If it's a new line item, put -1 for the content within the node. If it's an existing line you're trying to update, put the TxnLineID value of the existing line in there.
Example:
...
<InvoiceLineMod>
<TxnLineID>-1</TxnLineID>
<ItemRef>
<ListID>8000000A-1442469770</ListID>
<FullName>Item 1</FullName>
</ItemRef>
<Quantity>1</Quantity>
<Rate>1100.00</Rate>
</InvoiceLineMod>
...
<?xml version="1.0" encoding="UTF-8"?>
<searchResult>
<pagination>
<itemsPerPage>{Number of Inventories per Page}</itemsPerPage>
<numberOfItems>{Number of Inventories}</numberOfItems>
</pagination>
<itemList>
<item>
{Requested Salesforce fields e.g:}
<Id>{Salesforce Id}</Id>
<Name>{Name}</Name>
<pb__IsForSale__c>{e.g.}false</pb__IsForSale__c>
<pb__IsForLease__c>{e.g.}true</pb__IsForLease__c>
<pb__ItemDescription__c>{Item Description}</pb__ItemDescription__c>
<pb__PurchaseListPrice__c>{Item List Price e.g.:}2000000.00</pb__PurchaseListPrice__c>
<CurrencyIsoCode>{Currency Iso Code e.g:}EUR</CurrencyIsoCode>
<pb__UnitBedrooms__c>{Number of Bedrooms}</pb__UnitBedrooms__c>
<asset>
<Id>{internal Propertybase InventoryAsset Id}</Id>
<category>{Images, Videos or Documents}</category>
<isExternalLink>false</isExternalLink>
<title>{title}</title>
<filename>{original name of the uploaded file}</filename>
<url>{full url to image/video/document}</url>
<thumbnailUrl>{full url to thumbnail image}</thumbnailUrl>
<midresUrl>{full url to thumbnail image}</midresUrl>
<tags>{comma separated tags}</tags>
<mimeType>{e.g. image/jpeg}</mimeType>
</asset>
<asset>
<Id>{internal Propertybase InventoryAsset Id}</Id>
<category>{Images, Videos or Documents}</category>
<isExternalLink>true</isExternalLink>
<title>{title}</title>
<url>{full url to image/video/document}</url>
<tags>{comma separated tags}</tags>
</asset>
<asset>
{...}
</asset>
{more assets ...}
</item>
<item>
{...}
</item>
{more items ...}
</itemList>
</searchResult>
Well I have the above XML from which I need to store the item tag in a database table along with its child nodes as attributes, and have to store the asset tag and its child nodes in another table with the item id as foreign key from the item table, How do I do it done a lots of googeling but can't get of a way to get it to work
You simply need to select all Item nodes.
Using XPath (with SelectNodes, for example) this would be \\Item - this will produce a node set that you can iterate over.
I am trying to get the data from input xml message using functoids. But this doesn't seem to work. Below is my XML snippet
<?xml version="1.0" ?>
<ROOT>
<COMPANIES>
<COMPANY>
<NAME>FOO CORP</name>
</COMPANY>
<COMPANY>
<NAME>ACME CORP</name>
</COMPANY>
</COMPANIES>
<INFORMATIONS>
<INFORMATION>
<TESTING>
<TESTS>
<NAME>1221</NAME>
<TEST>
<TEXT>I AM SAM</TEXT>
</TEST>
</TESTS>
<TESTS>
<NAME>21</NAME>
<TEST>
<TEXT>FADFDF</TEXT>
</TEST>
</TESTS>
<TESTS>
<NAME>3001</NAME>
<TEST>
<TEXT>SGFGSDFG</TEXT>
</TEST>
</TESTS>
<TESTS>
<NAME>4569</NAME>
<TEST>
<TEXT>12312</TEXT>
</TEST>
</TESTS>
</TESTING>
<INFORMATION>
</INFORMATIONS>
</ROOT>
First I am trying to loop through COMPANY and get the NAME "ACME CORP". but which ever functoid i use (scripting, string extract etc) I always get the FOO CORP. I even tried inline XSLT but that also doesn't seem to work. Any idea how to get the 2nd COMPANY name?
Secondly, I have mapped <TEXT> directly to <node> in my destination schema. What i get is only 2 values from <TEXT>. Not all the <TEXT> are mapped to my <node>. Output i am getting is
I don't get is
I AM SAM
FADFDF
I don't get
<node>SGFGSDFG</node>
<node>12312</node>
Any one knows how i could get the values?
Thanks in advance
cheers,
Karthik
Q1: How to get the NAME of the second COMPANY?
1) Add Iteration functoid (Advanced Functoids) and connect to COMPANY node in your source schema
2) Add Equal functiod (Logical Functoids) and connect to Iteration functoid
3) Configure Equal functoid; add constant value 2
4) Add Value Mapping (Flattening) functoid (Advanced Functoids)
5) Connect output of Equal to input of Value Mapping
6) Connect NAME emlement of source schema to input of Value Mapping
7) Connect output of Value Mapping to destination schema element
Q2: Not all source TEXT elements are transformed to destination node
This seems to be a side effect of your mapping concering Q1 and I cannot reproduce your error.
Check minOccurs and maxOccurs of your source and destination schema for the elements/nodes in question.