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

XML in Powershell for beginners :)

I have the following XML structure:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<roles version="2.0">
	<role id="7722" name="System1">
		<system permission="allow"/>
		<folders permission="allow"/>

Open in new window

(read XML)

How do I add a role? (including childs)

How do I delete a role? (including childs)

(and save to file)

Thanks in advance

Keep up with what's happening at Experts Exchange!
LVL 12
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

How can i access the type Attributes directly if my XmlNode holds the below xml file.

i tried the following with no luck
dim elementPath as String = "ns:RequestedAddr/ns:type"
dim elementPath as String = "ns:RequestedAddr/type"
dim elementPath as String = "RequestedAddr/type"

Dim myNode As XmlNode = node.Attributes(elementPath)

I need to check if the node / Attribute exists to avoid null exceptions

        <RequestedAddr type="unknown">12099925140</RequestedAddr>
        <DestAddr type="e164">+12099925140</DestAddr>
        <RoutedAddr type="national">2099925140</RoutedAddr>
        <CallingPartyRoutedAddr type="national">2099313552</CallingPartyRoutedAddr>
        <CallingPartyOrigAddr type="national">2099313552</CallingPartyOrigAddr>

Open in new window

Experts, please let me know if you can recommend any free XML validation tool (not the generic plugins available in Notepad++, browser, etc) which is more advanced in terms of debugging the errors. Please recommend only if you have personally used it.
Hi Experts

Could you clear what is and what is causing this VFP  XML Web Service, correctly registered when running?

if the line
leResult = loHello_Port.sayHello('xxx')

Open in new window

is ommited - no problems arises

if the line is changed to:
leResult = loHello_Port.sayHello()

Open in new window

this error arises

<definitions name = "HelloService"
   targetNamespace = "http://www.xxxxx.com.br/soap/HelloService.wsdl"
   xmlns = "http://schemas.xmlsoap.org/wsdl/"
   xmlns:soap = "http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:tns = "http://www.xxxx.com.br/wsdl/HelloService.wsdl"
   xmlns:xsd = "http://www.w3.org/2001/XMLSchema">
   <message name = "SayHelloRequest">
      <part name = "firstName" type = "xsd:string"/>
   <message name = "SayHelloResponse">
      <part name = "greeting" type = "xsd:string"/>

   <portType name = "Hello_PortType">
      <operation name = "sayHello">
         <input message = "tns:SayHelloRequest"/>
         <output message = "tns:SayHelloResponse"/>

   <binding name = "Hello_Binding" type = "tns:Hello_PortType">
      <soap:binding style = "rpc"
         transport = "http://schemas.xmlsoap.org/soap/http"/>
      <operation name = "sayHello">
         <soap:operation soapAction = "sayHello"/>
               encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"

Open in new window


I wants til insert a xml node/node with child into an existing XML fil.
But I need it to be after a specific node :) -  "OrderReference"

The Existing File looks like this :
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href=""?>
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ccts="urn:oasis:names:specification:ubl:schema:xsd:CoreComponentParameters-2" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:sdt="urn:oasis:names:specification:ubl:schema:xsd:SpecializedDatatypes-2" xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 UBL-Invoice-2.0.xsd">
						<cbc:ID schemeID=""></cbc:ID>

Open in new window

Hello, I have a table which has a xml column and two varchar columns, and I would like to send this table as an email report.
I used SQL Server Database mail and scripts similar as below, but the xml column becomes NULL in the email report.   May I ask if someone knows how I can send the email, with both varchar data and xml data? I would like the xml data to show in xml format so that user can click on it for more details..  Thanks in advance :-)

SET @tableHTML =
body {font-family: Verdana;}
 N'<table border="1" width="90%">' +
      CAST ( ( SELECT td = Duration,'',
                    td = SessionID, '',
                    td = SQL_Text, ''
  from Table FOR XML PATH('tr'), TYPE  
    ) AS xml ) +     N'</table><br><br>'    ;
declare @subject varchar(300)
select @subject='email report'
EXEC msdb.dbo.sp_send_dbmail
@subject = @subject,
@body = @tableHTML,
@body_format = 'HTML'
I am going to try and explain this the best I can and I hope everyone understands and can help.  
*****I am not sure if in the XML file what I am referring to is called a Node, Boundary Tag, or Element. So I will call it a Node.****

I am importing a XML file into MS Access by VBA and when I do this Access separates the Children Nodes from the Parent Node and makes the Children Nodes tables and then puts the Grandchildren Nodes in the Children table as Field Names.

Here is a XML sample:
<?xml version="1.0" encoding="utf-8"?>

Open in new window

In my scenario here Access Makes these table:

These Fields:

So how can I get Access to either import all the Children and Grandchildren into a single table or how can I link these tables to show John Doe was OrderID 1234????

Thank you for the help?
My company has recently re-branded and I have created new PowerPoint, Excel and Word templates.
In Office I have created my colour palettes which are very useful, but these dont go across with the PowerPoint/Excel/Word files.

Ive been looking into it and it create an XML file on the machine with all the colours within that palette.
C:\Users\user\AppData\Roaming\Microsoft\Templates\Document Themes\Theme Colors\Name.xml

I would like an easy way for everyone else in the company to copy this XML onto their computer.

Can this be done with a batch script??

Any advice?

How can I convert xml files to jpeg?
I have a string which I need to find in all XML files. I am using notepad ++.



Open in new window

I need to find all files which contain 'ST2' in PARA APPLIC and PARA element should be followed by XREFXT element with XIDTYPE="GRAPHIC"



Open in new window

'X' represents wild character.

ST2 can be anywhere places in the APPLIC example:

Get your problem seen by more experts
LVL 12
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

I need some help in understanding how OPENXML works when shredding a XML document into a normal T-SQL rowset.
Please examine the query below and explain to me the meaning of the '../@Customerid' part of it.
This gives the results as they should be, but I notice that '@ProductID' does not have '../' before it.
I think that this has got to do with the path  '/ROOT/Customer/Order/OrderDetail'.
But if I insert '../' before '@ProductID' and '@Quantity' then those values appear as NULL, which does not make sense to me.

 DECLARE @DocHandle int  
DECLARE @XmlDocument nvarchar(1000)  
SET @XmlDocument = N'<ROOT>  
<Customer CustomerID="VINET" ContactName="Paul Henriot">  
   <Order OrderID="10248" CustomerID="VINET" EmployeeID="5"  
      <OrderDetail ProductID="11" Quantity="12"/>  
      <OrderDetail ProductID="42" Quantity="10"/>  
<Customer CustomerID="LILAS" ContactName="Carlos Gonzlez">  
   <Order OrderID="10283" CustomerID="LILAS" EmployeeID="3"  
      <OrderDetail ProductID="72" Quantity="3"/>  
-- Create an internal representation of the XML document.  
EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument  
-- Execute a SELECT statement using OPENXML rowset provider.  
FROM OPENXML (@DocHandle, '/ROOT/Customer/Order/OrderDetail',2)  
      WITH (OrderID     int         …
SQL To update a text value with xml inside of the column.

For example...and please note...the node I need to change will never be in the same order.....and will not have the same date value.


Here is the example.  Note I need to change the DATEPASSCHANGE value to todays date....regardless of the date.  

So I guess I need some query that will find the node...as it could be anywhere in the string....and then take whatever the value is and make todays date.

Please help...I only know how to do this with one value if I knew what the value I was changing was and I have thousands of these records in different orders with different dates.

I'm trying to find a script that will allow me to join about 30 PC to the domain with powershell or other methods.
I try two different power shell scripts and I get this error ps1 cannot be loaded because running scripts is disabled on this system.
I try to add on the beginning of the script the following line but that did not help. Set-ExecutionPolicy Unrestricted.
I also use Kaseya to push scripts and I found a few scripts on txt format but they need to be under XML format so I convert a txt file to a xml file online but that did not work eider.
Any suggestion how I can achieve that by pushing a script to all PC's.
The script can be push and execute it by Kaseya VSA as long as the script works.
How can I remove an xml node from an XmlDocument object in c#?  For example, I want to remove <LastName> tag.....


Open in new window

Desired Result:


Open in new window

I'm using .NET Framework 3.5
How do I correct my code so that when I send an xml in string over a post that it does not loose the white space in between the attributes

Abbreviated code is as follows
Piece 1:  Word VBA Macro
                        strBudgetRows = strBudgetRows & "<Detail BT20OBJ=""BT20.GLKKeyMaster"" Prop=""TitleDl""/>"
                        strBudgetRows = strBudgetRows & "<Detail BT20OBJ=""BT20.GLOObjMaster"" Prop=""ObjDl""/>"
                    strBudgetRows = strBudgetRows & "</ReportFormat>"
                strBudgetRows = strBudgetRows & "</ReportFetch>"
            strBudgetRows = strBudgetRows & "</Request>"
        strBudgetRows = strBudgetRows & "</NetSightMessage>"
    strBudgetRows = strBudgetRows & "</sbixml>"

    Set curlss = CreateObject("Microsoft.XMLHTTP")
    curlss.Open "POST", "https://", False
    curlss.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    curlss.send ("str=" & strBudgetRows)
    'curlss.responseText comes back with no spaces between attributes
    ActiveDocument.Tables(3).Cell(1, 1).Range.Text = curlss.responseText

Piece 2: Classic asp code
      dim strBudgetRows
      strBudgetRows = request("str")

      set xmlBudgetRows = Server.CreateObject("Microsoft.XMLDOM") : xmlBudgetRows.async = false : xmlBudgetRows.loadXml strBudgetRows
        response.write strBudgetRows
Piece 3:  XML is consumed in Piece 2 but the white space is gone, thus the .loadxml fails
I am creating an XML file on a web server using php; technique is perfect. I save the file to a folder on the web server, then download it using ftp & open in Excel, works perfect.

The real intent is to run a chron job weekly at a predetermined time that will create the xml file & email it to recipients as an attachment. I am using the class phpmailer. It sends the email, with attachment correctly, but it cannot be opened using Excel (at least in Windows).

How can I force it to recognize that I want it opened in Excel without having each recipient have to screw with their own associations of extensions.

Here is my code for the mailing:

// send_urpt.php
function date_conv($x) {
 $r = substr($x,5,2) . "/" . substr($x,8,2) . "/" . substr($x,0,4);
 return $r;
$mail             = new PHPMailer(); // defaults to using php "mail()"

$mail->isSMTP(); // telling the class to use SMTP transport
$body             = "";
$mail->SMTPSecure = $GLOBALS['smtp_security'];
$mail->Port       = $GLOBALS['smtp_port'];
$mail->AddReplyTo("lit@lakos.com", "replyto");
$body = "Attached is the usage report for the hvac configurator for the period " . date_conv($_SESSION['psat']) . " through 5PM Pacific Time on " . date_conv($_SESSION['currfri']) . ".";

Open in new window

I have a @var coming in as XML

I need a function to parse the variable below so I have a data row
Name                            SalesSIteID
Grand Vacations          103405

DECLARE @var1 XML = '<Response><Name>Grand Vacations</Name><SalesSiteID>103405</SalesSiteID></Response>'
I am trying to parse a .svg file to be able to write data for this particular website. A sample file can be found at

The web page is

an extract from the data file is reproduced at the bottom

Descriptions of .svg files tell that the data area is d=....  wherein M means move to and is followed by coordinates. Then lower case l (L) followed by a series of coordinates forming a path.

The problem is that in the data following the lower case l I see many numbers separated by spaces but within the spaces there are many decimal points so I do not see how it delimits the numbers/coordinates. Can someone help me out. Is there any other topic area where this question would be relevant?

<path class="border country" id="za" d="M450.942 336.32l.55 2.942.03.68.572 1.374.42 1.906-.004 3.927-.082 1.09-.173.08-1.027-.787-.468.325-.91 1.91-.02 1.072.915.614 1.74.033-.084.774-.432 1.767-.275 1.987-.562 1.414-.582.732-.56.327-.998 1.478-.372.713-.33 1.04-1.654 3.585-.714 1.18-.53.497-1.37 1.786-.61.976-2.24 2.547-1.764 1.568-1.46.8-.99-.163-.758.464-.032.54-1.43-.126-.396.655-.52.018-.93-.38-1.345-.255-.714.322-1.61-.238-.693.198-1.028 1.017-1.216.115-.425-.142-1.195.33-1.146 …
powershell find value of a xml tag in the attached xml

I want to find the COEStatusCode (in this case its unknown)

I tried $xmldata = [xml] (Get-Content https-photos.xml)
and then $xmldata.Objs.Version.COEStatuscode but it doesnt look like I am doing the right thing.

I'd like to know how to parse such xmls.

Thank You!
Free Tool: ZipGrep
LVL 12
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

We have 10 users in our Ms Access application and each is given specific rights by using VBA as below, for example managerial rights:
Private Sub Form_Open(Cancel As Integer)
Dim strITManager As String
strITManager = "Managers"
If Forms!frmLogin!txtUserrights.Value <> [strITManager] Then
MsgBox "You are not authorized to open this form!", vbOKOnly + vbExclamation, "Rights Not Granted"
Cancel = True
Exit Sub
End If
End Sub
The above method works very well with the current XML ribbon, but each and every users will have a chain of buttons which they cannot use or denied access, so instead of using the above VBA I want to hide those buttons that are not required by certain users using a better method if there is any. The challenge here is that I’m using an XML ribbon I do not know whether that can work here, below is a sample:
<button id="PosDelPurchases" imageMso="MasterViewClose" onAction="PosDelPurchases" label="Delete Wrong Purchases"  showImage="true"/>
The above ribbon uses the macros as follows:
(1)      Macro name = PosDelPurchases (onAction="PosDelPurchases")

So in short what I want to hide here is the button id (PosDelPurchases) and the label (label="Delete Wrong Purchases") but authorized users should be allowed to see them.

If the above can work then the software can be easy to use because users will have specific buttons to see and use.

Option available: Since I have seven modules as below could it be okay to create specific ribbons per module and …
How can I capture in SQL only the part that says OU=447 (or whatever number shows up)?  I actually only need the number part.

picture of string
I have this script to give me all the numbers in the string however, I still am not sure how to get the OU number by itself

T2(number)  AS (SELECT 1 FROM T1 AS a cross join T1 as b),
T3(number)  AS (SELECT 1 FROM T2 AS a cross join T2 as b),
T4(number)  AS (SELECT 1 FROM T3 AS a cross join T3 as b),
from T4)
(SELECT   '' + SUBSTRING(UserDN,Nums.number,1)
FOR XML PATH('')),1,0,'') as 'num'
from SSOLogs
I am having trouble pulling the miles from the XML. What am I doing wrong?

Below is the XML code that is returned by Google maps:

<?xml version="1.0"?>
    <origin_address>165 Kingsley St, Long Branch, NJ 07740, USA</origin_address>
    <destination_address>1600 Pennsylvania Ave NW, Washington, DC 20500, USA</destination_address>
                <text>3 hours 38 mins</text>
                <text>217 mi</text>

Open in new window

This is my Class module code for the form that sends the parameters:

Private Sub cmdCalculate_Click()

    Me.IDistance = GetDistance(Me.FromAddress, Me.ToAddress)

End Sub

'* Fetches Google map query results, returning travel time and mileage *

Public Function GetDistance(origin_address As String, destination_address As String)

Dim strURL              As String
Dim oXH                 As Object
Dim strBodytxt          As String
Dim strDistance         As String
Dim dblRoundTrip        As Double
Dim docDOM              As DOMDocument60
Dim objRoot             As 

Open in new window

I am using SQL Server to create a query(update statement)

The update statement is against a data  type of text.

Within the text is xml data.

Here is what I need to do.

I have some 3000 records that sometimes the xml tag is there and soemtimes its not.

I need to be able to add about 5 xml tags to each row in this field called msettings.
If the tag inside of msettings exists I need to be able to either override it or keep it the same.   It would be nice to construct the query so that could be optional depending on the situation.
And then ofcourse if the tag does not exist I would want it to append to the xml.  I do not think order matters as these are just tags...so its more like metadata


update table
set msettings =
where something = something

Please help...im not sure if I should be doing xpath...or some other logic.
I was hoping to make a robust solution as I could see reusing this later
I want to add a new task and associated group to the backstage of PowerPoint using the fluent UI XML method, although the same issue occurs for Excel and Word.

Using the Microsoft-published list of idMso control IDs I've established that the structure of the tab I'm interested in as as shown below:

PowerPoint backstage, Export tab
So to append a new task control to the end of the collection of 5 built-in tasks, this is the XML I'm using:

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
		<!-- Office Export Tab -->
		<tab idMso="Publish2Tab">
				<taskFormGroup idMso="PublishGroup">
					<category idMso="FileTypes">
						<task id="myTask" label="My Task">
							<group id="myGroup" label="My Group"/>

Open in new window

But when loading the project containing this same XML in PowerPoint, Excel or Word, I get this error:

Failed to find Office control by ID
ID: PublishGroup

I know the control ID is correct, even it it's swapped regarding Microsoft's normal naming convention because if I try taskFormGroup idMso="GroupPublish", I get the expected unknown error message instead:

Unknown Office control ID: GroupPublish

So do I have the XML structure wrong?
My question is there any way for me to integrate the 3 prongs of my stored procedure and thus allow me to put all the data points in the node into one data table. I am working in MS SQL
The xml code as follows:
               <CardiacAction ID="12-Lead EKG">12-Lead EKG</CardiacAction>
              <EnteredBy ID="586807">xxxxxxxxxxxx</EnteredBy>
              <Procedure ID="Cardiac">Cardiac</Procedure>
              <Comments>12-Lead EKG performed by xxxxxr. Successful.  Authorization: Via Protocol. </Comments>

Open in new window

The stored procedure is as follows:
insert into #tempDATA5
SELECT A.EventID.value('.', 'Varchar(20)') AS MedicationDT
FROM   @xml.nodes('/PCRDATA/Activity/Procedures/Procedure/EventID') A(EventID)
insert into dbo.ProcedureList
select @PRID_S,  Meds,(row_Number() OVER (ORDER BY @PRID_S )),@PRID_S+'-'+ convert(varchar(10),(row_Number() OVER (ORDER BY Meds ))) from #tempDATA5

insert into #tempDATA6
SELECT A.[Procedure].value('.', 

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).