XML Parsing in SharePoint file

asif ahamed 201 Reputation points
2021-09-20T19:13:14.98+00:00

Is there a way to parse this xml file got it from sharpoint
<?xml version="1.0"?>
<xml xmlns:z="#RowsetSchema" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882">
<s:Schema id="RowsetSchema">
<s:ElementType rs:CommandTimeout="30" content="eltOnly" name="row">
<s:AttributeType rs:name="Title" name="ows_LinkTitle" rs:number="1">
<s:datatype dt:maxLength="512" dt:type="string"/>
</s:AttributeType>
</s:ElementType>
</s:Schema>

<rs:data>
<z:row ows_Created="2021-09-20 12:57:40" ows_Hardware="Yes" ows_IT_x0020_Applications_x0020_List="Domain/Windows/Network ID eMail (Exchange/Outlook) VPN My Cloud (ERP) Additional Responsibilities My Development " ows_NewHireN="5" ows_Additional_x0020_Information="Ship iPhone and Macbook to below address, using the cost center 201.0000.01933.55133.000.0000.0000 Address: Syed ANinja 1034 BRADLEY TERRACE Chicago, IL L9T 5S7 Phone: 416-555-5555 " ows_Peer_x0020_Comments="Please ship a macbook pro 13" from Cyber security's lot of macbooks. " ows_Peer="10374;#i:0#.w|domain\itsec_consultant" ows_Cost_x0020_Center=" 201.0000.01933.55133.000.0000.0000" ows_isStandard="iPhone" ows_Extension_x0020_Needed="No" ows_Computer_x0020_Hardware="Yes" ows_Mobile_x0020_Phone="Yes" ows_New_x0020_Phone="Yes" ows_IT_x0020_Applications=";#Domain/Windows/Network ID;#eMail (Exchange/Outlook);#VPN;#Oracle Cloud (ERP) Additional Responsibilities;#I Development;#" ows_Effective_x0020_Start_x0020_Date="2021-09-27 00:00:00" ows_isManager="No" ows_New_x0020_Hire_x0020_Role="IT" ows_New_x0020_Hire_x0020_Address="300 Marco Blvd" ows_New_x0020_Hire_x0020_City="Paris" ows_New_x0020_Hire_x0020_Province="ILI a" ows_New_x0020_Hire_x0020_Employee_x0="226953" ows_New_x0020_Hire_x0020_Job_x0020_T="help desk" ows_New_x0020_Hire_x0020_Department="Enterprise Architecture" ows_New_x0020_Hire_x0020_Last_x0020_="Ahmed" ows_New_x0020_Hire_x0020_First_x0020="Syed" ows_Work_x0020_Status="Full Time" ows_New_x0020_Hire_x0020_Type="Permanent " ows_Office_x0020_Phone_x0020_Number="6478826765" ows_Submitter_x0020_Name="8179;#i:0#.w|domain\testUser" ows_LinkTitle="New Hire"/>
</rs:data>
</xml>

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,352 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rich Matheisen 44,621 Reputation points
    2021-09-21T02:31:07.82+00:00

    Once you clean up the quoting problem in that XML file you can deal with it like this:

    $xml = [xml](get-content c:\junk\xml.xml)
    

    Having namespaces in the XML makes navigating slightly more difficult, but let's say you wanted to get the entire "row":

    $row = $xml.xml.data.row
    

    If you want to pull out individual attributes of a row:

    $xml.xml.data.row.ows_Created
    
    # Or, using the $row variable from the previous example
    
    $row.ows_Created
    
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Rich Matheisen 44,621 Reputation points
    2021-09-20T22:54:27.033+00:00

    I think that file needs to be cleaned up. You've got a mixture of single and double quoted strings, and one of the attributes, specifically the attribute ows_Peer_x0020_Comments, is incorrect.

    The value of the attribute contains three double-quotes, the 2nd of which terminates the value prematurely:

    ows_Peer_x0020_Comments="Please ship a macbook pro 13" from Cyber security's lot of macbooks. "

    0 comments No comments

  2. Limitless Technology 39,336 Reputation points
    2021-09-21T12:10:43.607+00:00

    Hello,

    Thank you for reaching out.

    You can use lxml

    Please have al look on below Microsoft article : https://learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/aa543819(v%3Doffice.14)

    Thank you,

    0 comments No comments

  3. Limitless Technology 39,336 Reputation points
    2021-09-21T17:50:24.147+00:00

    Hello again @asif ahamed

    There are many also forums for this that you can try out
    https://social.technet.microsoft.com/wiki/contents/articles/19753.sharepoint-read-xml-file-from-document-library.aspx

    Check the accepted answer in this forum
    https://powerusers.microsoft.com/t5/Building-Flows/parse-xml-file-from-sharepoint-library/m-p/846227#M118414

    --If the the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments