Extensible Markup Language (XML) refers to the encoding of documents such that they can be read by both machines and humans. XML documents use tags to show the beginning and end of a set of data. XML is used extensively on websites to show volumes of data, and is the default for a number of office productivity suites. This topic includes discussions of XML-related technologies, such as XQuery (the XML Query language), XPath (the XML Path language), XSLT (eXtensible Stylesheet Language Transformations), XLink (the XML Linking language) and XPointer (the XML Pointer language).

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi Experts,

sample xml of type string
 String xmlStr = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"+
            "<Tutorial id=\"1\"><technology>Dot net, Java, Big data, Database</technology>\n"+

Open in new window

i want to pass this  xmlStr to  rest-api webservice to conusme it.

request method -post,
acceptable -contente type is -->application/xml

i am having doubt do i need to convert this xmlStr  to XML or i can pass this xmlStr  directly
if possible please provide sample.

Microsoft Azure 2017
LVL 13
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Delphi XML Data Bindings are proving tough to code for me. Learning how-to the correct way is my goal here. With the attached XML file, I am simply stuck as to the next thing I do to get any data into a memo control.

I am using Delphi 10.3 Community version, and am creating a new firemonkey app.

If someone could show how to get the most basic data out from the XML file attached onto a memo, it would be a great leap forward for me.

For clarity, I'm pretty much new to Delphi and I have tried many online resources (videos, tutorials, blogs) to get to grips with this, but even the included Delphi help file has minimal information as guidance.
I have the following dynamic sql.  I am having to run it this way because I did not want to hardcode the table name...

With that being said a new problem has occured.  i have another variable of XML type @ProjectXML.

When I use it it does not allow the string concatenate for @projectxml.nodes do to it being xml type versus string.

I have attempted to CAST to get around this but does not work.

Any ideas?

set @Query2 = 'select t1.*, t2.ProjectDescription, t3.OBOther 
		into ' + @TableName + '


		(Select * from ##T2)t1

		  Left Join

		(Select  n.value(''*:ProjectDescription[1]'',''nvarchar(MAX)'') as ProjectDescription,'
				 + @ReqID + ' as RequestId        						
				FROM ''' + CAST(@ProjectXML as NVARCHAR(MAX)) +'''.nodes(''/*:AppropriationRequestForm/*:RequestHeader'') AS ProjectXML(n))t2	
		  on t1.RequestID = t2.RequestId

		  Left Join

		(Select n.value(''*:OBOther[1]'',''nvarchar(MAX)'') OBOther,'
				+ @ReqID + 'as RequestId      
		  from ''' + CAST(@ProjectXML as NVARCHAR(MAX)) +'''.nodes(''/*:AppropriationRequestForm/*:OperationalBenefit'') AS ProjectXML(n))t3

		 on t1.RequestID = t3.RequestId'

Open in new window

SQL Server Query to get the values  of  an xml file.

I have a Node in XML called ProjectDescription.
It has a parent Called RequestHeader
Which has a parent called AppropriationRequestForm.

Within the ProjectDescription Node there could be an empty value
or there could be another child node with or without a value.
and so on up to 8 children.

I need my query to return the following result.

It needs to search for Project Description Node
Iterate through all child nodes until it finds the last child node of this parent.
Then that will be the value for Project Description.

Another scenario is the value of project description could be returned as a concatenation of all childnodes and values belonging to ProjectDescription.

An example of the one path..just keep in mind there could be more or less child nodes under ProjectDescription.


For purpose of testing:


                              DROP TABLE #AR

set @ProjectXML = '<?xml version="1.0"?><?mso-infoPathSolution …
Please help - I need to refactor the query to order the result set based on the order of the values in the xml file its reading.  
for example if RequestId was the first xml node then I would want that to return first.

The way I have this query formatted it is returning alphabettically.

n.value('local-name(.)','NVARCHAR(MAX)') AS Name, 
n.value('text()[1]','NVARCHAR(MAX)') AS Value 
FROM @ProjectXML.nodes('//*') AS ProjectXML(n)
Where n.value('local-name(.)','VARCHAR(100)')
not in

   select @cols = STUFF((SELECT distinct ',' + QUOTENAME(Name) 
                    from #AR2
            FOR XML PATH(''), TYPE
            ).value('.', 'NVARCHAR(MAX)') 

   set @query = 
'SELECT ' + @cols + ' INTO AR from 
              select Name, Value
			  from #AR2
            ) x
                for Name in (' + @cols + ')
            ) p ORDER BY RequestID'


Open in new window

I load an xml file dynamically.

Some of the xml files have some html tags that I need to clean out.

I cannot simply ignore the tag as that will remove the content within that element.

For example for a given xml file suppose I have this structure:

<html xmlns="http://www.w3.org/1999/xhtml" xml:space="preserve">

In this scenario I would want the contents of the <p> to be the ProjectDescription.

Is there a function or methodology that I can use to manipulate this?

I need to build a SQL function that will clean an XML file of bad characters thus making an  xml-safe version.
Otherwise my query will fail.

Within my stored proc I have the following variables:
Declare @fileData  XML

@fileData is loaded from disk with an xml file.

I tried to do this:

EXEC dbo.escapeXml @fileData
SET @ProjectXML = @fileData

I get the following error upon executing the stored proc that calls this function.

Implicit conversion from data type xml to nvarchar(max) is not allowed. Use the CONVERT function to run this query.

here is the function
ALTER FUNCTION [dbo].[escapeXml] 
(@xml nvarchar(max))
RETURNS nvarchar(max)
    declare @return nvarchar(max)
    select @return = 
                    REPLACE(@xml,'&', '&amp;')
                ,'<', '&lt;')
            ,'>', '&gt;')
        ,'"', '&quot;')
    ,'''', '&#39;')

return @return

Open in new window

I use this xml later in my proc.  It would be better if I could just clean the XML file but it seems it needs to be in a string format to do this.

So at some point if I have to convert  to nvarchar I need these files back to XML after they are cleaned.

Please help.
Please help me with a SQL Merge:

1st)  I create a query to generate a table dynamically.  This query has a pivot in it as the data comes from XML and this level of formatting from the query is required.
2nd)  I create a query the same way as above with the only difference being its a new xml file with the same structure.  This structure can have 200+ rows pivoted to columns so I have no plan on hard coding values for this to work.

Problem:   I need a way to get this 2nd, 3rd, and so on into the original table I created.
Assumption:  Since the structure though dynamic will be the same in each of the files I can use Merge?

I only see examples of using merge with table variables or static tables versus temp tables.  
Can I do this with this approach and if so please help.

Otherwise is there another option.

Here is the query that creates the database.  Keep in mind the same query or query result would be used if we were doing a merge I would think:

This pulls an xml file into a temp table ...then formats it with pivot to create a table.  Its reading these values as string so the database just puts them in at varchar(max)  This is ok as this will be run just one time and never again.  So please do not get bogged down in items related to column structure.   as this query is structured its brining in integer, date, string properly.    Once this data is properly in SQL it will be exported to Excel.

I read these xml files in a loop so this code  below would …

Dynamics 365 9.1,  

We are working on converting SQL SSRS reports to FetchXML for the Dynamics 365 Online environment.  We have completed most of a report but still have the following to convert:

select Value
from FilteredStringMap
where FilteredViewName ='FilteredFEI_nanoportdemo'
and attributename = 'fei_nano_nnplocation'

Open in new window

<fetch mapping="logical" version="1.0">
  <entity name="StringMap">
    <attribute name="Value" />
      <condition attribute="ViewName" operator="eq" value="FEI_nanoportdemo" />
      <condition attribute="attributename" operator="eq" value="fei_nano_nnplocation" />

Open in new window

We can query the Stringmap in SQL and can see it Fetchxml Builder but cant link the stringmap/option set to the report

Please help clean this process up.  I am getting errors that my TempAR is in the database but It never lets me drop it.  Sais it doesnt exist or I dont have permission.  This didnt start happening until I put the if else logic in place along with the Begin End statements.

Hopefully cleaning this up can add to clarity.  Here is what I have so far.

High level this reads an xml file in from the drive....builds an initial insert statement into the database using the first file it reads which creates column names.

Going forward I only want to insert the values...but again they need to match what the columns would be.

In each method I do the ame insert to an attachments table.

USE SharePoint2007Archive

RECONFIGURE -- To update the currently configured value for advanced options.
EXEC sp_configure 'xp_cmdshell', 1  -- To enable the feature.
RECONFIGURE -- To update the currently configured value for this feature.

CREATE TABLE #tmp(excelFileName VARCHAR(100));
EXEC xp_cmdshell 'dir /a-d /B E:\AR';

declare @fileName varchar(100)

Declare @fileData  XML
DECLARE @ReqID nvarchar(50)

DECLARE @ParmDefinition nvarchar(500); 
DECLARE @SQLString nvarchar(MAX);


    @query  AS NVARCHAR(MAX)

SET @Counter = 1;


While (Select Count(*) From #tmp where excelFileName is not null) > 0
	    SET @Counter = @Counter + 1
		Select Top 1 @fileName =

Open in new window

Fundamentals of JavaScript
LVL 13
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

I have a group of XML files in the following format.   Regardless of the nesting seen here I need to create this to a table.  This is a simplified format.  of the orginal file but should adhere to the structure.   In every xml file the requestID would be the primary key.  Regardless of the nesting if a Node has a value or is empty then it would be a column in the same table.  So for example in the xml file you would have RequestId, OBEnvironmental, PaybackPeriod,MIRR, TotalLeaseRevenues, LeaseTerm,FASTestPerformed,MIRRText,TotalLeaseRevenuesgText,LeaseTermText, AssignedProjectManager   all of these as columns.
And any value if there is one to be stored with the column.  Can I write a cte that will iterate this xml and perform this operations.  I have thousands of these type of xml files that used to be infopath forms that I need to move to SQL and am only concerned with conserving the data with a meaninful column name derived by the node where the data lives.  It could be several child levels deep at times..but any parent node that doesnt have data should just be ignored.

    <my:PaybackPeriod xsi:nil="true"></my:PaybackPeriod>
          <my:MIRR xsi:nil="true"></my:MIRR>

Open in new window

List of XML files to be dyanamically converted to a SQL Server database.

I have a list of folders on a network.
Each folder represents an info path form...essentially a folder of XML folders.

I need to iterate through the folder tree and create a database table for each set of xml files.

I would like to create a dynamic structure that will create the column names based on the nodes.

Please help.
Greetings Experts!

Working with vbscript and a limited (but growing, thanks to help received here!) knowledge of XML files, I'm trying to create a function that totals the quantities of materials issued to jobs by lot, bin, and serial number.  My XML file contains both material allocations (i.e. materials needed but not yet used) and material postings (i.e. specific information about materials that have been used).

In words, here’s what I’m trying to do:

For each material allocation, check to see whether the allocation has been completed. If it has not been completed, extract some information about the allocation from the XML and store it in a variable.  If it has been completed, look in the material postings and total up the quantities posted by lot, bin location, and serial number then store only those postings where the total quantity is not zero in the variable.

My latest attempt at this involved loading the material postings elements into an array and looping through that looking for lots that match the current lot and adding up the quantities. It kinda works but this will certainly take too long when my BOM has 500 items on it instead of 5 items.  Code shown here for context.

' create array of material postings
Dim arrMaterialPostings
arrMaterialPostings = BuildMaterialPostings(StockCodeSelection.CodeObject.Job)

Dim objDom, objAllocationsList, Counter, MyXML, objSerialNode, objBinNode, strBin, strSerial, EmptyXML
Dim objNodeList2, Counter2, 

Open in new window

I am trying to traverse xml returned from fedex's api to get a specific value.

i successfully make my call and get my response but i keep getting "PHP Notice: Trying to get property 'StatusDetail' (or 'Code') of non object in /myfile/"

this is how i try to access the returned data from fedex:


       $response = curl_exec($ch);
        $responseXml = simplexml_load_string($response);
// i even tried $responseXml = new SimpleXMLElement($response);
        $deliveryStatus = (string) $responseXml->CompletedTrackDetails->TrackDetails->StatusDetail->Code;

Open in new window

this is the xml:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header />
      <TrackReply xmlns="http://fedex.com/ws/track/v16">
            <Message>Request was successfully processed.</Message>
            <LocalizedMessage>Request was successfully processed.</LocalizedMessage>
            <CustomerTransactionId>Track By Number_v16</CustomerTransactionId>

Open in new window

i'm using Notepad++ to read my xml.
I noticed that a particular element is incrementing with each record.
For example, T2018-1, T2018-2, T2018-3, etc...

Is there a way I can do a find and replace for for all of them like T2018-* and replace it with just 11-1?
I'm open to suggestions, because the alternative is to manually change each element.
Hi all.

I'm working on a SSIS package, I have an "Execute SQL Task" which will email me the results of a sql query in an html table. I'm getting the following error:

"The query failed to parse. The FOR XML clause is invalid in views, inline functions, derived tables, and subqueries when they contain a set operator. To work around, wrap the SELECT containing a set operator using derived table syntax and apply FOR XML on top of it."

I think it has to do with the UNION ALL in the query, I've used the same type of Execute SQL Task for other sql queries that are emailed to me with no issues, but this one is the only one with a UNION ALL. Does anyone have any idea how to fix this?

SET @tableHTML =
    N'<H1>Below are the results</H1>' +
    N'<table border="1">' +
    N'<tr><th>Account ID</th>'+
    N'<th>Table Name</th>'+

    CAST( ( SELECT  td=  CRMAccount.AccountID,'' , td='CRMAccount' 
                      [ID Cross Reference].dbo.tblReference ON CRMAccount.AccountID = CAST([ID Cross Reference].dbo.tblReference.Division AS nvarchar(10)) 
                      + N'-' + CAST([ID Cross Reference].dbo.tblReference.ReferenceID AS nvarchar(10))
WHERE     (CAST([ID Cross Reference].dbo.tblReference.Division AS nvarchar(10)) + N'-' + CAST([ID Cross Reference].dbo.tblReference.ReferenceID AS nvarchar(10)) IS NULL)


  SELECT   td=  CRMAttachment.AccountID,'', td = 

Open in new window

I have the following input xml that I want to sort by /root/Traveler/@Type
I'm not concerned with ordering of the LastName or FirstName, precedence is attribute Type.

	<Traveler Type="ADT" AscID="T1">
	<Traveler AscID="T2" Type="CNN">
	<Traveler AscID="T3" Type="CNN">
	<Traveler AscID="T4" Type="ADT">
		<Infant AscID="T4.1" Type="INF">

Open in new window

Expected result:

	<Traveler Type="ADT" AscID="T1">
	<Traveler AscID="T4" Type="ADT">
		<Infant AscID="T4.1" Type="INF">
	<Traveler AscID="T2" Type="CNN">
	<Traveler AscID="T3" Type="CNN">

Open in new window

I had tried doing the below but it did not always worked, it seems to have taken into account the TravlerName

    var nodeComplete = domReq.Root.SelectSingle("CompletePNRElements");
    domReq.SortNodes(nodeComplete, "Traveler", "@Type", "XMLDOM_SORT_ASCENDING");
I need some advice on getting variables out of an XML response to a curl post.

The curl produces an xml response, eg:

<?xml version="1.0"?><ncresponse
TICKET="No Transaction found"

Open in new window

How do I extract each of the variables to use for further processing with PHP
Dear Experts,
the below code, it works perfectly fine,

$xmlDATA = '<?xml version="1.0" encoding="utf-8"?><VposResponse><MerchantId>000000000125427</MerchantId><TransactionType>Sale</TransactionType></VposResponse>';

$xml = simplexml_load_string($xmlDATA);

echo $MerchantId = $xml->MerchantId;
echo "<br><br>";
echo $TransactionType = $xml->TransactionType;

Open in new window

however it doesn't work, altough it is the same data.

 $xmlDATA = htmlentities($_POST["BankResponse"]);

$xml = simplexml_load_string($xmlDATA);

echo "MerchantId :" .  $MerchantId = $xml->MerchantId;
echo "<br><br>";
echo "TransactionType :" . $TransactionType = $xml->TransactionType;

Open in new window

I don't understand why it is not working. what do you suggest I should do?
CompTIA Security+
LVL 13
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

I am trying to insert this statement:
(SELECT STUFF((SELECT ',' + CAST(SEQUENCE_NO AS varchar(10)) + '-' + CASE WHEN OPERATION_TYPE IS NOT NULL THEN OPERATION_TYPE ELSE CASE WHEN SERVICE_ID IS NOT NULL THEN SERVICE_ID ELSE RESOURCE_ID END END FROM dbo.CT_Dashboards_Operations WITH (NOLOCK) WHERE (dbo.CT_Dashboards_Operations.TYPE = owo.TYPE) AND (dbo.CT_Dashboards_Operations.BASE_ID = owo.BASE_ID) AND (dbo.CT_Dashboards_Operations.LOT_ID = owo.LOT_ID) AND (dbo.CT_Dashboards_Operations.SPLIT_ID = owo.SPLIT_ID) AND (dbo.CT_Dashboards_Operations.SUB_ID = owo.SUB_ID) AND (dbo.CT_Dashboards_Operations.SEQUENCE_NO < op.SEQUENCE_NO) AND ((RESOURCE_ID <> 'INFO') AND ((OPERATION_TYPE <> 'QC_MTR') OR (OPERATION_TYPE IS NULL)) AND (NDE_Type IS NULL)) OR ((OPERATION_TYPE = 'QC_MTR') AND (LaborTicketCount = 0)) OR ((NDE_Type = 'XR') AND (Complete <> 1)) OR ((NDE_Type IS NOT NULL) AND (NDE_Type <> 'XR') AND (Qty_Accepted = 0)) FOR XML PATH('')), 1, 1, '') FROM dbo.CT_Dashboards_Operations)

Open in new window

Into this view:

SELECT        TOP (100) PERCENT owo.SITE_ID, dbo.SHOP_RESOURCE_SITE_VIEW.USER_1 AS Dashboard_Group, owo.PullDate, dbo.CT_InvDash_Items_Pass_06_All_Demand_Summary.MinOfPullDate, CASE WHEN MinOfPullDate IS NULL
                          THEN PullDate ELSE MinOfPullDate END AS PriorityDate, CASE WHEN Op.RESOURCE_ID = 'ASSY' THEN CASE WHEN op.OPERATION_TYPE LIKE 'HARDNESS%' OR
                         op.OPERATION_TYPE LIKE 'MARK%' THEN 'OTHER' ELSE 'ASSY' END ELSE 

Open in new window

Given this information...
POST /Sale/Application/v2/mypage.asmx HTTP/1.1
Host: b2b2.mywebsite.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/Persist"

Open in new window

How would I post my xml data to a service in vb.net web page win 4.5 environment

I do NOT want to import the wsdl
Looking for a powershell script that sets locale for all servers to Ireland

Is there a handy way to do this?

Do i need to use it a regional XML file as link below

 Server 2012 core with 2 VMs. VM1 had a usb drive attached for backup.
When swapping drive, forgot to remove it in VM1 before I unplugged the cable to the usb drive. Couldn't start VM1 w/o drive at all. Got it reconnected. It didn't show up in VM settings under controller 0. Tried to re-add  it in settings but errors that the drive is already attached. Went into the xml file and removed anything pertaining to the usb drive and I must have taken out something I shouldn't have and it said it couldn't find the file. I'm pretty bad at xml'
Any ideas now to reconnect (or remove and re-add it) the usb drive to the virtual machine. I have the machine files. Would deleting the vm and creating a new vm and attaching the machine file. Any suggestions are very welcome.
Below is an excerpt of the XML code used to create the Ribbon in Access.

The bit I can't get to grips with is where are the images held for each button? It is defined here:  imageMso=""FileCheckIn"
So is the image "FileCheckIn" held within Access? In which case, how do I find the list of images that I can use? Or do I have to import them in?

The code is:
ID	RibbonName	RibbonXML
1	Dashboard	"<customUI xmlns=""http://schemas.microsoft.com/office/2006/01/customui"">
  <ribbon startFromScratch=""true"">
      <tab id=""tabDashboard"" label=""Dashboard"" visible=""true"">
        <group id=""grpJobSheet"" label=""Job Sheet"">
          <button id=""btnArtwork"" size=""large"" label=""Artwork"" imageMso=""PhotoAlbumInsert"" onAction=""mcrgBillableTaskRecent.OpenBillableTaskRecentAP""/>
          <button id=""btnWeb"" size=""large"" label=""Web"" imageMso=""ViewWebLayoutView"" onAction=""mcrgBillableTaskRecent.OpenBillableTaskRecentW""/>
          <button id=""btnIn_houseProduction"" size=""large"" label=""In-house Production"" imageMso=""FileCheckIn"" onAction=""mcrgOrderProduction.OpenOrderProductionNoSupplier""/>

Open in new window


I have the below xml stuff inserted into a clob column in a dummy table. I am aware that ideally it needs to be an xmltype column in the table but it is not possible to change from clob to xmltype now. Hence need your help with the extract and extractvalue functions to get the node values out from the below. I am not an expert into the xml world and hence please suggest.

<?xml version="1.0"?>
<tns:FIToFI xmlns:outdir="http://www.abcd.co.in/v2/outdir" xmlns:head="urn:iso:std:iso:20022:tech:xsd:head_pacs008.001.001.01" xmlns:pt="urn:iso:std:iso:20022:tech:xsd:pacs.008.001.04" xmlns:pt_supp="urn:cash:std:xsd:supp.pacs.008.v2" xmlns:tns="urn:cash:std:xsd:FIToFI">

Open in new window







Extensible Markup Language (XML) refers to the encoding of documents such that they can be read by both machines and humans. XML documents use tags to show the beginning and end of a set of data. XML is used extensively on websites to show volumes of data, and is the default for a number of office productivity suites. This topic includes discussions of XML-related technologies, such as XQuery (the XML Query language), XPath (the XML Path language), XSLT (eXtensible Stylesheet Language Transformations), XLink (the XML Linking language) and XPointer (the XML Pointer language).