parsing problem with xml definitions

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!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rastoiWindows DTS expertCommented:
probably due to invalid xml format. tha t "version" inside <XD> field cancels further interpreting.
there no correct xml structure inside and whole part between <XD> and </XD> is represented like one string
rastoiWindows DTS expertCommented:
I played a bit with and this transformation makes the trick

[xml]$a =get-content C:\https-photos.xml 

Open in new window

with output:

ns1                  : Output:EBSHRIS:Timesheet:List
COEStatusCode        : UNKNOWNERROR
 COEStatusDescription : the HTTP response code of 500 indicated a server error. The response data may contain a reason.
ResultCount          :
ResultList           :

so you can query then $b.xml.Envelope.body.PhotoList.COEStatuscode directly
No need for character based editing here. That is valid xml, and it's just an exported/serialized xml PowerShell variable.
So all you need to do is import the file, and you can access the real xml directly:
$xml = Import-Clixml -Path C:\Temp\https-photos.xml
$COEStatusCode = $xml.Envelope.Body.PhotoList.COEStatusCode

Open in new window

Once imported back into PS, the xml looks like that, btw:
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="" xmlns:soapenc="" xmlns:xsi="" xmlns:xsd="">
		<ns1:PhotoList xmlns:ns1="Output:EBSHRIS:Timesheet:List">
			<COEStatusDescription>the HTTP response code of 500 indicated a server error. The response data may contain a reason.</COEStatusDescription>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DevSupportAuthor Commented:
Thank You so much!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.