XML issue parsing !CDATA

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Liam Kemp Liam Kemp 2 months, 3 weeks ago.

  • Author
    Posts
  • #67683
    Profile photo of ndlang
    ndlang
    Participant

    I am pretty new to PowerShell. I am having an issue converting returned XML from Fogbugz to a CSV file. It looks like the issue is in most of the fields the string is wrapped in.

    Below is the command I am using.

    $resp = Invoke-RestMethod $url
    $resp.response.cases.case | ConvertTo-csv

    Sample from output ("xxxx" removed information):
    "ixBug","operations","sTitle","sStatus","sVersion","sPersonAssignedTo","sFixFor","sPriority","tags"
    "xxxxx","xxxxx","System.Xml.XmlElement","System.Xml.XmlElement","","System.Xml.XmlElement","S
    ystem.Xml.XmlElement","System.Xml.XmlElement","System.Xml.XmlElement"
    "xxxxx","xxxxx","System.Xml.XmlElement","System.Xml.XmlElement","","System.Xml.XmlElement","S
    ystem.Xml.XmlElement","System.Xml.XmlElement","System.Xml.XmlElement"

  • #67735
    Profile photo of Liam Kemp
    Liam Kemp
    Participant

    Hi

    I'd be interested to know if you run $resp.response.cases.case without converting to CSV, do you see the data as you expect it to look?
    The !CDATA flags are just there to tell the XML parser "Look at this stuff like regular text" so that it doesn't accidentally parse something that might look like an XML tag when it isn't, so it shouldn't be causing you any trouble. The CDATA content should just end up as the value of the corresponding key.

    Liam

You must be logged in to reply to this topic.