XmlElement itemNameRq = inputXMLDoc.CreateElement("FullName"); itemNameRq.InnerText = "563"; itemQryRq.AppendChild(itemNameRq); itemNameRq = inputXMLDoc.CreateElement("FullName"); itemNameRq.InnerText = "ND-105"; itemQryRq.AppendChild(itemNameRq);>This is the code to create a qbxml file and sending it to QB:
> XmlDocument inputXMLDoc = new XmlDocument(); > inputXMLDoc.AppendChild(inputXMLDoc.CreateXmlDeclaration("1.0", null, null)); > inputXMLDoc.AppendChild(inputXMLDoc.CreateProcessingInstruction("qbxml", "version=\"2.0\"")); > XmlElement qbXML = inputXMLDoc.CreateElement("QBXML"); > inputXMLDoc.AppendChild(qbXML); > XmlElement qbXMLMsgsRq = inputXMLDoc.CreateElement("QBXMLMsgsRq"); > qbXML.AppendChild(qbXMLMsgsRq); > qbXMLMsgsRq.SetAttribute("onError", "stopOnError"); > XmlElement itemQryRq = inputXMLDoc.CreateElement("ItemInventoryQueryRq"); > qbXMLMsgsRq.AppendChild(itemQryRq); > > XmlElement itemNameRq = inputXMLDoc.CreateElement("FullName"); > itemNameRq.InnerText = "563"; > itemQryRq.AppendChild(itemNameRq); > > itemNameRq = inputXMLDoc.CreateElement("FullName"); > itemNameRq.InnerText = "ND-105"; > itemQryRq.AppendChild(itemNameRq); > > string input = inputXMLDoc.OuterXml; > //step3: do the qbXMLRP request > RequestProcessor2 rp = null; > string ticket = null; > string response = null; > try > { > rp = new RequestProcessor2(); > rp.OpenConnection("", "IDN Inventory Item Request"); > ticket = rp.BeginSession("", QBFileMode.qbFileOpenDoNotCare); > response = rp.ProcessRequest(ticket, input); > > } > catch (System.Runtime.InteropServices.COMException ex) > { > MessageBox.Show("COM Error Description = " + ex.Message, "COM error"); > return; > } > finally > { > if (ticket != null) > { > rp.EndSession(ticket); > } > if (rp != null) > { > rp.CloseConnection(); > } > }; > > //step4: parse the XML response and show a message > XmlDocument outputXMLDoc = new XmlDocument(); > outputXMLDoc.LoadXml(response); >>