XML Tools Plugin: "Pretty Print" not working- is it the file?
-
Hi all, I have an XML file I want to “Pretty Print” with separate lines and indentations. I thought I’d done this plenty of times in the past with NPP. But nothing in the XML plugin seems to work with this file.
It’s a.xml. I have NPP 8.1.2 64 bit. XML Tools plugin 3.1.1.6 64 bit. Windows 10.
The one thing that may be weird in this file is that it contains a bunch of data with CRLF (or CR, not sure- it’s just this element appears in NPP over multiple lines, which makes sense given the source data for this xml).
So I have one loooonggg line on top with a bunch of tags and elements. That line ends with the <comment> tag and the first line of the comments section. That is followed by a bunch of other lines of the comment section. The final line starts with the </comment> tag, followed by oodles of other tags and elements.
So I fire up the XML Tools plugin, and when I select either “Pretty Print” or “Pretty Print - indent attributes”, nothing happens. I tried the corresponding keyboard shortcuts- still nothing. I tried CTRL-A selecting all the data in the file- still nothing. I went into the settings and tried each of the three available formatting plugins- still nothing gives me the pretty formatting.
What am I missing? I’m sure if done this successfully in the past. Thanks.
-
XML Tools works for me.
If I have an XML that looks like
and use Plugins > XML Tools > Pretty Print, it looks like
when done, which is what I’d expect.I’m using XML Tools Plugin 3.1.1.6-64bit with NPP v8.1.4-64bit.
Notepad++ v8.1.4 (64-bit) Build time : Aug 21 2021 - 13:04:59 Path : C:\Program Files\Notepad++\notepad++.exe Command Line : Admin mode : OFF Local Conf mode : OFF Cloud Config : OFF OS Name : Windows 10 Home (64-bit) OS Version : 2009 OS Build : 19043.1237 Current ANSI codepage : 1252 Plugins : ComparePlugin.dll ExtSettings.dll MarkdownViewerPlusPlus.dll mimeTools.dll NppConsole.dll NppConverter.dll NppEditorConfig.dll NppExec.dll NppExport.dll NppFTP.dll NppUISpy.dll PreviewHTML.dll PythonScript.dll QuickText.dll TagLEET.dll XMLTools.dll
Maybe if you find a small amount of XML that shows this problem (hopefully only requires a dozen or so lines, and if you need to, replace sensitive data with fake text), and put it in here using ``` on a line before and after (which you can get by selecting the pasted data and clicking the
</>
button in the forum editor pane)``` <NotepadPlus> <UserLang name="Jolly" ext="" udlVersion="2.1"> <Settings> <Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" /> <Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" /> </Settings> <KeywordLists> <Keywords name="Comments"></Keywords> <Keywords name="Numbers, prefix1"></Keywords> <Keywords name="Numbers, prefix2"></Keywords> <Keywords name="Numbers, extras1"></Keywords> <Keywords name="Numbers, extras2"></Keywords> <Keywords name="Numbers, suffix1"></Keywords> <Keywords name="Numbers, suffix2"></Keywords> <Keywords name="Numbers, range"></Keywords> </KeywordLists> </UserLang> </NotepadPlus> ```
so that it renders like
<NotepadPlus> <UserLang name="Jolly" ext="" udlVersion="2.1"> <Settings> <Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" /> <Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" /> </Settings> <KeywordLists> <Keywords name="Comments"></Keywords> <Keywords name="Numbers, prefix1"></Keywords> <Keywords name="Numbers, prefix2"></Keywords> <Keywords name="Numbers, extras1"></Keywords> <Keywords name="Numbers, extras2"></Keywords> <Keywords name="Numbers, suffix1"></Keywords> <Keywords name="Numbers, suffix2"></Keywords> <Keywords name="Numbers, range"></Keywords> </KeywordLists> </UserLang> </NotepadPlus>
The XML I show here will “linearize” and “pretty print” back and forth with no difficulty, whether using
Ctrl+A
or just letting XML Tools work with the whole window without a selection. -
Thanks Peter! Sorry for the tardy reply- doesn’t look like I’m getting notifications. Here’s the total .xml file. It’s a fire company incident record- no proprietary or confidential data in this one luckily. And yes, I’m with you- I’ve done this plenty in the past- I thought it would work flawlessly again, but I’m stumped!!
<Incident><Incidentnumber>00520</Incidentnumber><IncidentNFIRS>1800520</IncidentNFIRS><CADEventNumber></CADEventNumber><IncidentYear>2018</IncidentYear><fdid>38033</fdid><Agency></Agency><response_date>2018-01-05T04:19:32</response_date><location_name></location_name><Station>29</Station><District></District><Zone>52-11</Zone><map_grid>52</map_grid><AddressType>1</AddressType><house_number>614</house_number><prefix_directional></prefix_directional><name_component>SWEDE</name_component><street_type>ST</street_type><post_directional></post_directional><building></building><apt>2</apt><cross_street>W MARSHALL ST AND W CHESTNUT ST</cross_street><cross_street2></cross_street2><municipality>NRSN</municipality><city></city><STATE></STATE><ZIPCODE></ZIPCODE><LATITUDE></LATITUDE><LONGITUDE></LONGITUDE><caller_name></caller_name><call_back_phone></call_back_phone><caller_address></caller_address><alarmlevel></alarmlevel><incident_type>111</incident_type><incident_description>BUILDING FIRE COMMERCIAL[F1]</incident_description><time_911_call_taken>2018-01-05T04:07:06</time_911_call_taken><time_first_unit_assigned>2018-01-05T04:19:32</time_first_unit_assigned><time_first_unit_enroute>2018-01-05T04:19:33</time_first_unit_enroute><time_first_unit_arrived>2018-01-05T04:22:45</time_first_unit_arrived><time_last_unit_cleared>2018-01-05T05:32:06</time_last_unit_cleared><commentlist><comment>04:07 APT 2 IN THE REAR 04:07 CALLER SMELLS SOMETHING BURNING, SEES SMOKE 04:08 CALLER ADVISED TO EVACUATE 04:10 FEM ON THE LINE, STATING THERE IS SOMEONE IN AN APT AND CANT GET OUT 04:10 CALLER WAS UNCOOPERATIVE TO CTY, STATED THEY WERE HERE AND HUNG UP 04:11 52208-- SMOKE IN THE APT 04:13 -- page to 27 31 61 43 -- Note: AC27-WORKING FIRE 2ND FLR 04:13 AC27-GO WITH CONFIRMED WORKING FIRE 2ND FLR 04:15 AC27 -- IN COMMAND 04:18 212-- ON SWEDE BLOCKING OAK 04:19 211-- PERSON IN THE BACK OF MY VEH THAT IS A RES 04:19 PECO WITHIN THE HOUR 04:22 CMMD-REPLACE SD61 04:23 CMMD-PD STATING 04:25 CMMD-PD STATING THEY HAVE PEOPLE FROM THE BLDG WE ARE DOING SEARCHS NOW 04:26 SD48 SCRATCHED 04:27 52211-- ONE MALE TO 30 LINCOLN AVE 04:27 CMMD-WE HAVE FIRE ON 2 FLRS HAVE 2 LINES IN SERVICE SEARCHES ARE GOING ON NOW DC32 IS SEARCH SUPERVISOR FIRE IS DOUBTFUL AT THIS TIME 04:28 CMMD-STRIKE THE 2ND ALARM 04:31 52211 -- OUT ON LINCOLN AVE 04:31 CT308-3RD AMBULANCE AND SMART BUS 04:32 AC27-5 NOTIFY CH27 04:32 CMMD-2ND ALARM CO STAGE ON SWEDE STREET OR MARSHALL ST FROM DEKALB 04:33 STA44-BOTH TRKS ARE A SCRATCH 04:33 ****CMMD GIVEN 20 MM**** 04:35 CMMD-HAVE A LINE IN THE EXPOSURE PRIMARY AND SECONDARY SEARCH ARE IN PROGRESS FIRE IS STILL DOUBTFUL AT THIS TIME 04:35 OK ON CH27 04:37 -- page to 27 31 61 43 32 29 47 53 46 -- Note: INCOMING 2ND Alarm units stage SWEDE OR 04:37 MARSHALL ST PER CMD 04:38 PAWC ADVISED 04:41 CT308-SMART TO SWEDE/OAK 04:42 E83 E80 TO STA 27B -- L6 SD62 TO STA 27D 04:43 STA 33 RESPONSE CHECKED / SCRATCHED 04:44 R21 STANDBY IN YOUR STA 04:45 CH27-NEED PD TO CLOSE AIRY AND CHURCH AND MARSHALL AND DEKALB SO VEHICLES DONT RUN OVER THE { </comment></commentlist><Units><Unit><radio_name>E32</radio_name><ApparatusType>11 - Engine</ApparatusType><time_assigned>2018-01-05T04:19:32</time_assigned><time_enroute>2018-01-05T04:19:33</time_enroute><time_arrivedatscene>2018-01-05T04:22:45</time_arrivedatscene><time_depart_scene></time_depart_scene><time_arrive_destination></time_arrive_destination><time_in_service>2018-01-05T05:32:06</time_in_service><time_call_cleared>2018-01-05T05:32:06</time_call_cleared></Unit></Units></Incident>
-
doesn’t look like I’m getting notifications.
The forum notifications don’t work, sorry. (And they haven’t found a way to hide those notification settings, either. I wonder how many people assume they never got a reply and never come back when they never get notifications; unfortunately, nothing we’ve been able to do about it.)
Here’s the total .xml file
It was short enough to easily copy/paste, so I guess that’s not a problem.
I pasted it into a new Notepad++ v8.1.4 tab, changed that tab to XML, ran XML Tools 3.1.1.6-64bit Pretty Print on it (didn’t select anything, so it was the whole document), and it immediately and without difficulty it came up with:
<Incident> <Incidentnumber>00520</Incidentnumber> <IncidentNFIRS>1800520</IncidentNFIRS> <CADEventNumber/> <IncidentYear>2018</IncidentYear> <fdid>38033</fdid> <Agency/> <response_date>2018-01-05T04:19:32</response_date> <location_name/> <Station>29</Station> <District/> <Zone>52-11</Zone> <map_grid>52</map_grid> <AddressType>1</AddressType> <house_number>614</house_number> <prefix_directional/> <name_component>SWEDE</name_component> <street_type>ST</street_type> <post_directional/> <building/> <apt>2</apt> <cross_street>W MARSHALL ST AND W CHESTNUT ST</cross_street> <cross_street2/> <municipality>NRSN</municipality> <city/> <STATE/> <ZIPCODE/> <LATITUDE/> <LONGITUDE/> <caller_name/> <call_back_phone/> <caller_address/> <alarmlevel/> <incident_type>111</incident_type> <incident_description>BUILDING FIRE COMMERCIAL[F1]</incident_description> <time_911_call_taken>2018-01-05T04:07:06</time_911_call_taken> <time_first_unit_assigned>2018-01-05T04:19:32</time_first_unit_assigned> <time_first_unit_enroute>2018-01-05T04:19:33</time_first_unit_enroute> <time_first_unit_arrived>2018-01-05T04:22:45</time_first_unit_arrived> <time_last_unit_cleared>2018-01-05T05:32:06</time_last_unit_cleared> <commentlist> <comment>04:07 APT 2 IN THE REAR 04:07 CALLER SMELLS SOMETHING BURNING, SEES SMOKE 04:08 CALLER ADVISED TO EVACUATE 04:10 FEM ON THE LINE, STATING THERE IS SOMEONE IN AN APT AND CANT GET OUT 04:10 CALLER WAS UNCOOPERATIVE TO CTY, STATED THEY WERE HERE AND HUNG UP 04:11 52208-- SMOKE IN THE APT 04:13 -- page to 27 31 61 43 -- Note: AC27-WORKING FIRE 2ND FLR 04:13 AC27-GO WITH CONFIRMED WORKING FIRE 2ND FLR 04:15 AC27 -- IN COMMAND 04:18 212-- ON SWEDE BLOCKING OAK 04:19 211-- PERSON IN THE BACK OF MY VEH THAT IS A RES 04:19 PECO WITHIN THE HOUR 04:22 CMMD-REPLACE SD61 04:23 CMMD-PD STATING 04:25 CMMD-PD STATING THEY HAVE PEOPLE FROM THE BLDG WE ARE DOING SEARCHS NOW 04:26 SD48 SCRATCHED 04:27 52211-- ONE MALE TO 30 LINCOLN AVE 04:27 CMMD-WE HAVE FIRE ON 2 FLRS HAVE 2 LINES IN SERVICE SEARCHES ARE GOING ON NOW DC32 IS SEARCH SUPERVISOR FIRE IS DOUBTFUL AT THIS TIME 04:28 CMMD-STRIKE THE 2ND ALARM 04:31 52211 -- OUT ON LINCOLN AVE 04:31 CT308-3RD AMBULANCE AND SMART BUS 04:32 AC27-5 NOTIFY CH27 04:32 CMMD-2ND ALARM CO STAGE ON SWEDE STREET OR MARSHALL ST FROM DEKALB 04:33 STA44-BOTH TRKS ARE A SCRATCH 04:33 ****CMMD GIVEN 20 MM**** 04:35 CMMD-HAVE A LINE IN THE EXPOSURE PRIMARY AND SECONDARY SEARCH ARE IN PROGRESS FIRE IS STILL DOUBTFUL AT THIS TIME 04:35 OK ON CH27 04:37 -- page to 27 31 61 43 32 29 47 53 46 -- Note: INCOMING 2ND Alarm units stage SWEDE OR 04:37 MARSHALL ST PER CMD 04:38 PAWC ADVISED 04:41 CT308-SMART TO SWEDE/OAK 04:42 E83 E80 TO STA 27B -- L6 SD62 TO STA 27D 04:43 STA 33 RESPONSE CHECKED / SCRATCHED 04:44 R21 STANDBY IN YOUR STA 04:45 CH27-NEED PD TO CLOSE AIRY AND CHURCH AND MARSHALL AND DEKALB SO VEHICLES DONT RUN OVER THE {</comment> </commentlist> <Units> <Unit> <radio_name>E32</radio_name> <ApparatusType>11 - Engine</ApparatusType> <time_assigned>2018-01-05T04:19:32</time_assigned> <time_enroute>2018-01-05T04:19:33</time_enroute> <time_arrivedatscene>2018-01-05T04:22:45</time_arrivedatscene> <time_depart_scene/> <time_arrive_destination/> <time_in_service>2018-01-05T05:32:06</time_in_service> <time_call_cleared>2018-01-05T05:32:06</time_call_cleared> </Unit> </Units> </Incident>
-
Thanks so much Peter! Now I just have to figure out what the problem is with my implementation…will try on another machine and go from there. Interestingly, your example doesn’t seem to have worked perfectly- look at how the <CADEventNumber> gets munged. But that’s a topic I’ll explore once I get it to work on my machine…
thanks again!
Bucky
-
Hmmm, just copied and pasted into another window in my same NPP session, and it works there! Very strange! But will get me through.
Looks like any empty element tags get treated the same way here- instead of <element></element>, it ends up as <element/>.
That seems like it may be something about XML that I’m ignorant of…
-
@Bucky-Swider said in XML Tools Plugin: "Pretty Print" not working- is it the file?:
Hmmm, just copied and pasted into another window in my same NPP session, and it works there! Very strange! But will get me through.
Glad it’s working for you now.
Looks like any empty element tags get treated the same way here- instead of <element></element>, it ends up as <element/>.
That seems like it may be something about XML that I’m ignorant of…From what I understand, to the XML spec,
<XYZ></XYZ>
is exactly equivalent to<XYZ/>
– the second is a canonical shorthand for the first) -
I know this is an older thread but I’ve had this a few times and each time it was because the source file is read-only!
Seems obvious I guess but as there’s no error message it always gets me.